python
1import schedule 2import time 3import subprocess 4 5def task(name): 6 print(f"{name} is working") 7 8schedule.every(3).seconds.do(task("Mike")) 9while True: 10 schedule.run_pending() 11 time.sleep(1)
こちらを実行すると,the first argument must be callable
とエラーが出てきてしまいます.
引数を取らない関数ですと,
例)schedule.every(3).seconds.do(non_arg_func)
エラーを起こさず,実行できました.
引数を取る場合は,どのようにしたらエラーが発生しなくなりますでしょうか?
do メソッドの signature は、
do(self, job_func: Callable, *args, **kwargs)
となっていますので、schedule.every(3).seconds.do(task, "Mike") となるのではないでしょうか。
あなたの回答
tips
プレビュー