datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
比如要输出当前时间一小时之后的时间:
#coding:utf-8
from datetime import datetime,timedelta
time1 = datetime.now()
time1
#日期转为str
print (time1.strftime("%y-%m-%d %H:%M:%S"))
#当前时间后移1小时
print( (time1+timedelta(hours =1)).strftime("%y-%m-%d %H:%M:%S"))
网友评论