import time
def sleeptime(hour, min, sec):
return hour * 3600 + min * 60 + sec
second = sleeptime(0, 0, 7344000)
while 1 == 1:
time.sleep(second)
print('do action')
程序要85天执行一次
import time
def sleeptime(hour, min, sec):
return hour * 3600 + min * 60 + sec
second = sleeptime(0, 0, 7344000)
while 1 == 1:
time.sleep(second)
print('do action')
程序要85天执行一次
time.sleep(second)的second值太大了
你可以分成多次执行time.sleep()
代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)
import time
def sleeptime(hour, min, sec):
return hour * 3600 + min * 60 + sec
second = sleeptime(0, 0, 7344000)
while 1 == 1:
r = second
while r>1000000:
time.sleep(1000000)
r -= 1000000
time.sleep(r)
print('do action')