我想得到当前时间,并将其与小时整数相加。现在的例子是2019年5月12日晚上11点。我想再多加3个小时。所以结果是2019年5月13日凌晨2点。请帮助我输入datetime+hours(整数类型)
import datetime
currentDT = datetime.datetime.now()
print('Now is: '+ str(currentDT))
hours = int(input()) #any hours you want
result = currentDT + hours #it will get the errors here
使用
datetime.now
获取当前时间,并添加datetime.timedelta
:相关问题 更多 >
编程相关推荐