[英]Python AttributeError: partially initialized module
I'm making a script that runs the script every 10 seconds (for example)我正在制作一个每 10 秒运行一次脚本的脚本(例如)
But i get this:但我明白了:
AttributeError: partially initialized module 'schedule' has no attribute 'every' (most likely due to a circular import) AttributeError:部分初始化的模块 'schedule' 没有属性 'every'(很可能是由于循环导入)
My code:我的代码:
import schedule
import time
def job():
print("I'm working...")
schedule.every(3).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)
import schedule
import time
def job():
print("I'm working...")
schedule.every(3).seconds.do(job)
while True:
schedule.run.pending()
time.sleep(1)
Thanks to Azat Ibrakov & Abdul Aziz Barkat for saying that i need to rename my python script.感谢 Azat Ibrakov 和 Abdul Aziz Barkat 说我需要重命名我的 python 脚本。
Thanks to joao for saying that its "run_pending" and not "run.pending".感谢 joao 说它的“run_pending”而不是“run.pending”。
Working code:工作代码:
import schedule
import time
def job():
print("I'm working...")
schedule.every(3).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.