python應用操作——每天0點定時啟動
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()
點擊加載更多評論>>