python应用操作——每天0点定时启动
提问人:ylm发布时间:2020-09-29
from threading import Timerimport datetime
def fun():
print('Zarten')
timer = Timer(24*60*60, fun)
timer.start()
now = datetime.datetime.now()
tomorrow_time = now + datetime.timedelta(1)tomorrow_year = tomorrow_time.yeartomorrow_month = tomorrow_time.monthtomorrow_day = tomorrow_time.day
tomorrow_zero_time = datetime.datetime.strptime(str(tomorrow_year)+"-"+str(tomorrow_month)+"-"+str(tomorrow_day)+" 00:00:00", "%Y-%m-%d %H:%M:%S")
interval_time = (tomorrow_zero_time - now).total_seconds()
timer = Timer(interval_time, fun)timer.start()
继续查找其他问题的答案?
相关视频回答
回复(0)
点击加载更多评论>>