파이썬 현재시간, 날짜 표시하기 datatime
2022. 1. 29. 10:56ㆍPython/Python datetime 모듈
반응형
import datetime
##########################
# 일반 파이썬 시계
##########################
print(datetime.datetime.now())
present_now = datetime.datetime.now()
print(present_now)
##########################
# 연도, 일자, 시간, 나오도록 표시
##########################
import time
now = time.localtime()
print("%04d/%02d/%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec))
##########################
# 일자, 시간 나오도록 표시
##########################
import time
now = time.localtime()
print("%02d/%02d %02d:%02d" % (now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min))
##########################
# 시간, 분, 초 만 나오도록 표시
##########################
import time
now = time.localtime()
print("%02d:%02d:%02d" % (now.tm_hour, now.tm_min, now.tm_sec))
반응형