Python 3 sched module



我正在尝试创建一个脚本,该脚本将在每分钟的顶部运行代码。我正在研究调整模块,并且遇到了一些奇怪的问题。

第一个问题是导入计划两次运行我的脚本。

import sched
print('hello')

输出:

Hello
Hello

此外,该代码直接来自文档:

import sched, time
s = sched.scheduler(time.time, time.sleep)

产生此错误:

AttributeError: module 'sched' has no attribute 'scheduler'

按照我的评论 - 您的文件命名为 sched.py,因此,它正在自身导入,其中没有属性scheduler

最新更新