반응형 DateTime2 [Python] 현재 날짜 포멧 출력하기 from datetime import datetime format_data = "%Y-%m-%d %H:%M:%S.%f" now_str = datetime.now().strftime(format_data) print(now_str) # 2022-08-22 19:11:38.565332 포멧 종류는 아래와 같습니다. format code meaning example %a Abbreviated weekday name Sun, Mon %A Full weekday name Sunday, Monday %w Weekday as decimal number 0…6 %d Day of the month as a zero-padded decimal 01, 02 %-d day of the month as decimal numbe.. 2022. 8. 22. python 오늘날짜, 현재시간 now 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 2019. 2. 13. 이전 1 다음 728x90 반응형