【问题标题】:How to change a variable based on current time in python?如何根据python中的当前时间更改变量?
【发布时间】:2020-01-15 13:56:43
【问题描述】:

我想在第二天(即时间 = 00:00:00 时)将变量重置为 0。我该怎么做?

【问题讨论】:

  • if time == 00:00:00: variable = 0

标签: python variables time


【解决方案1】:

尝试使用datetime

from datetime import datetime

now = datetime.now()
if ( now.hour == 0 and now.minute == 0 and now.secound == 0 ) :
    # Do something

【讨论】:

    猜你喜欢
    • 2020-01-28
    • 2014-07-08
    • 1970-01-01
    • 2021-03-13
    • 1970-01-01
    • 2019-01-29
    • 2015-07-13
    • 1970-01-01
    • 2015-09-17
    相关资源
    最近更新 更多