问题描述
运行该计划后,我需要每小时重复一次该功能。
这是我的代码:
import schedule
import time
def main_job():
print('Hello World')
def schech():
schedule.every().minute.do(main_job)
while True:
schedule.run_pending()
time.sleep(1)
schedule.every().day.at("17:46").do(schech)
while True:
schedule.run_pending()
time.sleep(1)
我得到的错误:
RecursionError:超过最大递归深度
解决方法
删除schech()函数中的while循环。
import schedule
import time
def main_job():
print('Hello World')
def schech():
main_job()
schedule.every(60).minutes.do(main_job)
schedule.every().day.at("9:00").do(schech)
while True:
schedule.run_pending()
time.sleep(1)