我正在尝试使用APScheduler包在python中安排作业。这answer看起来很棒,但它的snytax已经过时了。我转到user guide获取当前版本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"
。