Python AttributeError:部分初始化的模块 [英] Python AttributeError: partially initialized module

查看:48
本文介绍了Python AttributeError:部分初始化的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个每 10 秒运行一次脚本的脚本(例如)

I'm making a script that runs the script every 10 seconds (for example)

但我明白了:

AttributeError: 部分初始化的模块schedule"没有属性every"(很可能是由于循环导入)

AttributeError: partially initialized module 'schedule' has no attribute 'every' (most likely due to a circular import)

我的代码:

import schedule
import time

def job():
    print("I'm working...")

schedule.every(3).seconds.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

推荐答案

感谢 Azat Ibrakov &Abdul Aziz Barkat 说我需要重命名我的 Python 脚本.

Thanks to Azat Ibrakov & Abdul Aziz Barkat for saying that i need to rename my python script.

感谢 joao 说它的run_pending"而不是run.pending".

Thanks to joao for saying that its "run_pending" and not "run.pending".

工作代码:

import schedule
import time

def job():
    print("I'm working...")

schedule.every(3).seconds.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

这篇关于Python AttributeError:部分初始化的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆