달나라 노트

Python datetime : now(현재 날짜와 시간) & today(현재 날짜) 본문

Python/Python datetime

Python datetime : now(현재 날짜와 시간) & today(현재 날짜)

CosmosProject 2020. 12. 23. 02:46
728x90
반응형

 

 

 

import datetime

current_dt = datetime.datetime.now()
print(current_dt)

- Result
2020-03-08 02:13:52.703621

datetime 모듈의 class중에서 datetime이라는 class가 존재합니다.
datetime class에 속한 now라는 moethod는 현재 local date와 time을 리턴합니다.

 

 

 

 

import datetime

current_dt = datetime.date.today()
print(current_dt)

- Result
2020-03-08

datetime 모듈의 class중에서 date라는 class가 존재합니다.
date class에 속한 today라는 moethod는 현재 local date를 리턴합니다.

 

 

 

 

 

 

728x90
반응형
Comments