less than 1 minute read

λ‚ μ§œμ™€ μ‹œκ°„

datetime module

  • date: λ…„, μ›”, 일
  • time: μ‹œ, λΆ„, 초, 마이크둜초
  • datetime: λ‚ μ§œμ™€ μ‹œκ°„
  • timedelta: λ‚ μ§œ 와/λ˜λŠ” μ‹œκ°„ 간격
from datetime import date
halloween = date(2019, 10, 31)
print(halloween)
print(halloween.day)
print(halloween.month)
print(halloween.year)

from datetime import timedelta
one_day = timedelta(days=1)
tomorrow = now+one_day
print(tomorrow)
print(now+17*one_day)
yesterday = now - one_day
print(yesterday)

from datetime import time
noon = time(12,0,0)
print(noon)
print(noon.hour)
print(noon.minute)
print(noon.second)
print(noon.microsecond)

from datetime import datetime
some_day = datetime(2015, 1, 2, 3, 4, 5, 6)
print(some_day)
print(some_day.isoformat())