【发布时间】:2017-09-11 18:30:54
【问题描述】:
在 Python 中使用 schedule 包时,我想安排一个任务在特定时间开始,然后每 10 秒运行一次。我能够使用schedule.every(10).seconds.do(x) 让任务每10 秒运行一次,并且我还使用schedule.every().day.at('13:25').do(x) 让它在设定的时间运行。但是我怎么把这些放在一起呢?我试图将它们组合成以下内容,但我得到了RecursionError: maximum recursion depth exceeded
import schedule
import time
def test():
print('Hello, World!')
def sched_job():
schedule.every(10).seconds.do(test)
while True:
schedule.run_pending()
time.sleep(1)
schedule.every().day.at('13:56').do(sched_job)
while True:
schedule.run_pending()
time.sleep(1)
sched_job()
【问题讨论】:
标签: python time scheduled-tasks schedule