2023.03.07
서론
저번주에 코테 준비하느라 바빠서 멘토링 리뷰를 작성하지 못했었다 ㅎㅎ
그래서 2차시 리뷰가 밀렸당 ㅎ..
새로 알게 된 내용만을 작성할 것이다.
<datetime 패키지>
datetime 패키지에는 날짜와 시간이 모두 저장되어있는 datetime 클래스, 날짜만 있는 date 클래스, 시간만 있는 time 클래스, 시간 구간 정보가 있는 timedelta 클래스 등이 있다.
import datetime 해줘야함
이번 멘토링 시간에서는 datetime 패키지의 datetime 클래스 만을 사용해보았는데 패키지 이름과 클래스 이름이 같기 때문에 처음에 조금 헷갈렸다.
datetime 클래스에 대해 알아보았다.
datetime 클래스의 대표적인 메소드에는 now()가 있다.
now()는 컴퓨터의 현재 시각을 datetime 객체로 만들어 반환한다.
year, month, day, hour, minutem second, microsecond, weekday, strftime 등의 속성이 있다.
이중 날짜와 시간 정보를 문자열로 바꿔주는 strftime 메소드도 많이 사용한다고 한다!
https://docs.python.org/ko/3/library/datetime.html?highlight=datetime#
datetime — Basic date and time types
Source code: Lib/datetime.py The datetime module supplies classes for manipulating dates and times. While date and time arithmetic is supported, the focus of the implementation is on efficient attr...
docs.python.org
<pass와 raise NotImplementedError>
pass와 raise NotImplementedError 모두 나중에 구현하려고 비워둔 구문을 처리할 때 사용하지만 pass 키워드는 아무 오류가 발생하지 않고 말그대로 pass가 되지만 raise NotImplementedError는 오류가 발생한다!
실무에서 pass를 쓰고 넘어갔다가 나중에 그 부분 개발하는 것을 까먹을 수 있으니 raise NotImplementedError를 사용하는 것도 좋을 것 같다.
pass 사용 예시 ↓↓↓↓↓
if number > 0:
pass
else:
pass
raise NotImplementedError 사용 예시 ↓↓↓↓↓
if number > 0:
raise NotImplementedError
else:
raise NotImplementedError
'Mentoring > Python' 카테고리의 다른 글
파이썬 멘토링#6 _함공파 - while문 (1) | 2023.05.20 |
---|---|
파이썬 멘토링#5 _함공파 (0) | 2023.04.13 |
파이썬 멘토링#4 _함공파 (2) | 2023.03.16 |
파이썬 멘토링#2 _함공파 (0) | 2023.02.27 |
파이썬 멘토링#1 _함께 공부하는 파이썬 (1) | 2023.02.26 |