right_now = datetime.datetime.now()
one_hour_before = ?????
如何使用right_now获取one_hour_before?
答案 0 :(得分:7)
right_now = datetime.datetime.now()
one_hour_before = right_now - datetime.timedelta(hours=1)
答案 1 :(得分:1)
你需要像datetime.timedelta
这样使用:
right_now = datetime.datetime.now()
one_hour_before = right_now - datetime.timedelta(hours = 1)