我正在尝试使用 APScheduler 包在 python 中安排作业。这个答案看起来不错,但它的语法已经过时了。我去了当前版本 3 的用户指南,但我找不到一个基本示例,我可以datetime
像链接答案中那样将对象传递给调度程序。
from datetime import date
from apscheduler.schedulers.background import BackgroundScheduler as Scheduler
from datetime import datetime
# Start the scheduler
sched = Scheduler()
sched.start()
# Define the function that is to be executed
def my_job(text):
print text
#Schedule job
job = sched.add_job(my_job, next_run_time = datetime(2015, 5, 11, 1, 05, 5), args = ['Hello World!'])
这会产生错误:No handlers could be found for logger "apscheduler.executors.default"
.