目录
第十章、datetime模块
一、datetime 模块
import datetime#返回当前时间print(datetime.datetime.now())
2019-08-19 15:05:13.321043
print(datetime.date.fromtimestamp(time.time()))#2019-08-19
#当前时间加3天print(datetime.datetime.now() + datetime.timedelta(3))#也可以-3天print(datetime.datetime.now() + datetime.timedelta(hours=3))#当前时间-3小时#也可以关键字minutes=30+30分钟
#时间替换replace方法c_time = datetime.datetime.now()print(c_time.replace(minute=20, hour=5, second=13))#2019-08-19 05:20:13.287023