如何使用 Python 在 Windows 上安排任务?

How do I schedule tasks on Windows using Python?

我有以下代码:

import schedule
import time

def job(t):
    print "I'm working...", t
    return

schedule.every().sunday.at("01:00").do(job,'It is sonday 01:00')

while True:
    schedule.run_pending()
    time.sleep(60) # wait one minute

如何确保代码在我的 PC 关闭或代码不是 运行 时正常工作?

我不知道我的问题是不是很奇怪,但是按照时间表,我们应该可以重复这个活动。而且我觉得只要代码是运行.

就可以了

或者很简单,当代码不是 运行 and/or 我的电脑关机时会发生什么?

使用OS 调度程序。如果 windows - 选择 https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10