Python线程模块导入失败

Tre*_*ent 15 python import multithreading

我正在尝试导入线程模块,但是,我似乎只是因为没有充分理由而得到错误.这是我的代码:

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()
Run Code Online (Sandbox Code Playgroud)

而错误:

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 . . .
Run Code Online (Sandbox Code Playgroud)

Python统计数据:

获胜32的Python 2.7.2(默认,2011年6月12日,15:08:59)[MSC v.1500 32位(英特尔)]

FoR*_*bia 54

我认为您只需重命名工作文件的名称,因为您的文件名与模块名称相同:

threading.py

或者您的工作目录中有错误的threading.py文件

  • 如果存在,也删除**threading.pyc**. (3认同)
  • 傻到我不要注意文件与模块同名:/ (2认同)