【发布时间】:2022-01-24 03:59:41
【问题描述】:
嘿,伙计们,这可能很愚蠢,但我无法找到解决方法...我试图每天运行我的 python 代码,并且我使用调度来执行此操作。但是,它会阻止到达root.mainloop(),因为之前存在无限循环。这是网站https://pypi.org/project/schedule/
如果有更好的方法来“安排”我的代码在某些日子的某个时间运行,我将不胜感激!这是下面的示例代码。
def job():
print("I am doing this job!")
schedule.every().monday.at("11:21").do(job)
schedule.every().tuesday.at("14:00").do(job)
schedule.every().wednesday.at("22:00").do(job)
schedule.every().thursday.at("14:00").do(job)
schedule.every().friday.at("14:00").do(job)
while True:
schedule.run_pending()
time.sleep(1)
root.mainloop()
谢谢!
【问题讨论】:
-
官方文档中有一个example在子线程中运行while循环。
标签: python tkinter automation scheduler