问题描述
我试图在每分钟开始时使用ApScheduler运行任务。当我运行下面的代码时,没有输出。有什么想法吗?
from apscheduler.schedulers.blocking import BlockingScheduler
scheduler = BlockingScheduler()
def hello():
print('hello')
scheduler.add_job(hello,'cron',minute=1)
scheduler.start()
解决方法
解决了!
原来,获得我想要的功能的方法是使用minute='*'
。使用minute=1
会在每小时的第一分钟(而不是每分钟的更改)运行hello函数。