在python中如何基于当前时间更改变量?

在python中如何基于当前时间更改变量?,python,variables,time,Python,Variables,Time,我想在第二天(即时间=00:00:00)将变量重置为0。我该怎么做?尝试使用datetime: from datetime import datetime now = datetime.now() if ( now.hour == 0 and now.minute == 0 and now.secound == 0 ) : # Do something 如果时间==00:00:00:variable=0

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

尝试使用
datetime

from datetime import datetime

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

如果时间==00:00:00:variable=0