标签:imp 返回 now() int min code date port ace
# datetime模块可以看成是时间加减的模块
import datetime
返回当前时间
print(datetime.datetime.now())
2019-08-16 19:33:39.557899
更改时间
# 当前时间+3天
print(datetime.datetime.now() + datetime.timedelta(3))
2019-08-19 19:33:39.557899
当前时间3小时
print(datetime.datetime.now() + datetime.timedelta(hours=3))
2019-08-19 22:33:39.557899
# 当前时间+3分钟
print(datetime.datetime.now() + datetime.timedelta(minutes=3))
2019-08-19 22:33:42.557899
时间替换
# 时间替换
c_time = datetime.datetime.now()
print(c_time.replace(minute=20, hour=5, second=13))
2019-08-16 05:20:13.617117
标签:imp 返回 now() int min code date port ace
原文地址:https://www.cnblogs.com/dadazunzhe/p/11403988.html