python- TypeError: func must be callable

python- TypeError: func must be callable

我想在我的项目中使用 apscheduler.scheduler,这是我的代码

import sys
from time import sleep
from apscheduler.scheduler import Scheduler

TOKEN = "****"

sched = Scheduler()
sched.start()

def my_job(text):
    print(text)

def main() :
    job = sched.add_date_job(my_job('25'), '2017-09-08 14:08:05', args=['text'])
    while True:
        sleep(1)
        sys.stdout.write('.'); sys.stdout.flush()

if __name__ == '__main__':
    main()

我遇到了这个异常

25
Traceback (most recent call last):
  File "F:\+faeze\workspace\testHelloWorld\src\test\testDateTime.py", line 22, in <module>
    main()
  File "F:\+faeze\workspace\testHelloWorld\src\test\testDateTime.py", line 16, in main
    job = sched.add_date_job(my_job('25'), '2017-09-08 14:08:05', args=['text'])
  File "C:\Python27\lib\site-packages\apscheduler\scheduler.py", line 318, in add_date_job
    return self.add_job(trigger, func, args, kwargs, **options)
  File "C:\Python27\lib\site-packages\apscheduler\scheduler.py", line 284, in add_job
    options.pop('coalesce', self.coalesce), **options)
  File "C:\Python27\lib\site-packages\apscheduler\job.py", line 47, in __init__
    raise TypeError('func must be callable')
TypeError: func must be callable

我哪里错了??

更新:TypeError: func must be callable是什么意思?

您应该修改以下行。

job = sched.add_date_job(my_job, '2017-09-08 14:08:05', ('25',))

这意味着 my_job 方法将在指定时间使用参数 25

调用