【发布时间】:2011-12-25 03:15:03
【问题描述】:
我正在尝试导入线程模块,但是,我似乎无缘无故地出错了。这是我的代码:
import threading
class TheThread ( threading.Thread ):
def run ( self ):
print 'Insert some thread stuff here.'
print 'I\'ll be executed...yeah....'
print 'There\'s not much to it.'
TheThread.Start()
还有错误:
Traceback (most recent call last):
File "threading.py", line 1, in <module>
import threading
File "C:\Users\Trent\Documents\Scripting\Python\Threading\threading.py", line
3, in <module>
class TheThread ( threading.Thread ):
AttributeError: 'module' object has no attribute 'Thread'
Press any key to continue . . .
Python 统计数据:
Python 2.7.2(默认,2011 年 6 月 12 日,15:08:59)[MSC v.1500 32 位 (英特尔)] 在 win 32 上
【问题讨论】:
-
您的当前目录中是否有名为“threading.py”的文件?如果是这样,这可能是没有 Thread 属性的原因。
-
如果之前运行过代码记得删除
threading.pyc
标签: python multithreading import