Job "1503281 (trigger: interval[0:01:00], next run at: 2018-06-01 23:54:36 CST)" raised an exception Traceback (most recent call last): File "/mnt/e/mitdo/lib/python3.5/site-packages/apscheduler/executors/base.py", line 125, in run_job retval = job.func(*job.args, **job.kwargs) TypeError: run() missing 1 required positional argument: 'self' Job "1426148 (trigger: interval[0:01:00], next run at: 2018-06-01 23:55:36 CST)" raised an exception Traceback (most recent call last): File "/mnt/e/mitdo/lib/python3.5/site-packages/apscheduler/executors/base.py", line 125, in run_job retval = job.func(*job.args, **job.kwargs) TypeError: run() missing 1 required positional argument: 'self'
报这种错,真是一脸蒙蔽。我往 Scheduler 里增加的任务是一个类的实例方法。就是这个 run()。这个方法是没有参数的,为啥他说缺 self 啊!!!!!
1
Arnie97 2018-06-02 01:39:24 +08:00 via Android
这跟 aps 没有关系,而是你根本不理解面向对象里的静态方法、类方法和实例方法…
Python 实例方法的第一个参数是显式的实例对象,这和某些魔法 this 的语言相反,好处是不易与另两种方法混淆,坏处是满篇都是 self。 |