본문 바로가기
Python

python 오늘날짜, 현재시간 now

by bryan.oh 2019. 2. 13.
반응형

python datetime

now

현재날짜, 시간

 

 

import datetime

now = datetime.datetime.now()
print(now)          # 2015-04-19 12:11:32.669083

nowDate = now.strftime('%Y-%m-%d')
print(nowDate)      # 2015-04-19

nowTime = now.strftime('%H:%M:%S')
print(nowTime)      # 12:11:32

nowDatetime = now.strftime('%Y-%m-%d %H:%M:%S')
print(nowDatetime)  # 2015-04-19 12:11:32
 

 

728x90
반응형

댓글