[英]Python schedule script running in IDLE but not in Visual Studio Code
The following test code runs perfectly in Python IDLE but in Visual Studio Code I get an error message that says: 以下测试代码可以在Python IDLE中完美运行,但是在Visual Studio Code中,我收到一条错误消息,内容为:
"AttributeError: 'module' object has no attribute 'every' ..." “ AttributeError:'模块'对象没有属性'每个'...”
import schedule
import time
def job(t):
print "I'm working..." , t
return
schedule.every().day.at("08:16").do(job,'hello')
while True:
schedule.run_pending()
time.sleep(60) # wait one minute
I am trying to schedule a recurring task in Python. 我正在尝试安排Python中的重复任务。 I've installed the schedule module and used the code to try it out. 我已经安装了schedule模块,并使用代码进行了试用。 Cleaning chache, renaming the file and re-writing it in a new file didn´t help. 清理文件,重命名文件并将其重新写入新文件并没有帮助。
How is it possible that a script runs in one application and not in the other?? 脚本怎么可能在一个应用程序中运行而不在另一个应用程序中运行? Does that make sense? 那有意义吗?
Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks in advance. 提前致谢。
Can you do: 你可以做:
from schedule import *
import schedule
Print: 打印:
print schedule.__file__
Also Be sure your file name, is not named: "schedule.py" 另外,请确保您的文件名未命名为:“ schedule.py”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.