【发布时间】:2021-02-19 11:01:27
【问题描述】:
我正在制作一个每 10 秒运行一次脚本的脚本(例如)
但我明白了:
AttributeError: 部分初始化的模块 'schedule' 没有属性 'every' (很可能是由于循环导入)
我的代码:
import schedule
import time
def job():
print("I'm working...")
schedule.every(3).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)
【问题讨论】:
-
你的文件名是什么?如果是
schedule.py将其更改为其他内容,您最终只会导入自身。 -
检查你的本地模块名称,可能其中一个叫做
schedule.py -
你的代码在我这边工作。你安装了
schedule包吗? -
你的文件名是什么?或者您的文件所在的文件夹中是否还有其他文件,名称类似于
schedule或time? -
您好!感谢您的回复,我调用了我的文件 schedule.py!我现在改名了。 schedule.run.pending() AttributeError: module 'schedule' has no attribute 'run'