将schedule作为变量传递以计划python

时间:2020-08-24 09:47:00

标签: python-3.x

我有以下代码,我正在使用python调度库来调度函数

import schedule
import time

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

schedule.every(10).minutes.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

我想将every(10).minutes.do(job)作为变量传递给计划,如下所示:

import schedule
import time

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

my_schedule = "every(10).minutes.do(job)"

schedule.my_schedule

while True:
    schedule.run_pending()
    time.sleep(1)

我该如何实现

0 个答案:

没有答案