Python线程模块导入失败 [英] Python threading module import failure

查看:89
本文介绍了Python线程模块导入失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to import the threading module, however, i just seem to get errors for no good reason. Here is my code:

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 stats:

Python 2.7.2(默认值,2011年6月12日,15:08:59)[MSC v.1500 32位 (Intel)]赢了32

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win 32

推荐答案

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

i think that all you need is just to rename the name of your working file, because your file name is the same as module name:

threading.py

threading.py

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

or you have wrong threading.py file in your working directory

这篇关于Python线程模块导入失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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