python datetime包的使用

python yekong 91℃

获取当前时间

from datetime import  datetime
print(datetime.now())

获取时间间隔

获取三天后
from datetime import datetime
from datetime import timedelta

now = datetime.now()
three_days = timedelta(days=3)
after_three_day = now + three_days
print(after_three_day)

喜欢 (0)