๋ฐ์ํ
import datetime
now = datetime.datetime.now()
one_day = datetime.timedelta(days=1)
one_hour = datetime.timedelta(hours=1)
# ํ์ฌ ๋ ์ง์ ์๊ฐ ์ถ๋ ฅ
# 2023-04-21 01:21:35.277992
print(f'now : {now}')
# ํ์ฌ ์ฐ๋์ ๋ ์ง๋ง ์ถ๋ ฅ
# 2023-04-21
print(f'now.date() : {now.date()}')
# ํ์ฌ ์๊ฐ๋ง ์ถ๋ ฅ
# 01:21:35.277992
print(f'now.time() : {now.time()}')
# ํ์ฌ ์ฐ๋๋ง ์ถ๋ ฅ
# 2023
print(f'now.year : {now.year}')
# ํ์ฌ ์๋ง ์ถ๋ ฅ
# 4
print(f'now.month : {now.month}')
# ํ์ฌ ์ผ๋ง ์ถ๋ ฅ
# 21
print(f'now.day : {now.day}')
# ํ์ฌ ์์ผ ์ถ๋ ฅ(0:์์์ผ ~ 6:์ผ์์ผ)
# 4
print(f'now.weekday : {now.weekday()}')
# ๋ ์ง๋ฅผ ํน์ ํ์์ผ๋ก ์ถ๋ ฅ
# 23/04/21-01:21:35
print(f'now.strftime("%y/%m/%d-%H:%M:%S") : {now.strftime("%y/%m/%d-%H:%M:%S")}')
# ๋ด์ผ์ ๊ณ์ฐํ๋ํ์ฌ ์ถ๋ ฅ
# 2023-04-22 01:21:35.277992
print(f'1 day later : {now + one_day}')
# 1์๊ฐ ํ๋ฅผ ๊ณ์ฐํ์ฌ ์ถ๋ ฅ
# 2023-04-21 02:21:35.277992
print(f'1 hour later : {now + one_hour}')
๋ฐ์ํ
'๐ Programming > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] collections Counter ์ฌ์ฉ๋ฒ (0) | 2021.09.06 |
---|---|
[Python] ๋ฌธ์์ด ๋ค๋ฃจ๊ธฐ (0) | 2021.08.21 |