Python中threading的问题

当编写python线程代码时如出现一下错误的解决方案

start main at:  Fri May  6 17:59:37 2016
Traceback (most recent call last):
  File "./th.py", line 28, in <module>
    main()
  File "./th.py", line 18, in main
    t = threading.Thread(target=loop,args=(i,loops[i]))
AttributeError: 'module' object has no attribute 'Thread'
Exception AttributeError: '_shutdown' in <module 'threading' from '/home/lvlup/mypython/pythontext/threading.py'> ignored

说明在你的目录下有一个和python中重名的文件就是threading.pyc和threading.py,解决此问题方法是
一,如果编写的文件名字是threading.py 把名字改掉并且把threading.pyc 编译的文件删除掉
二,如果是没有用的文件就直接删除掉就好了

自己编写的文件尽可能的不要和系统再带的文件重名。


版权声明:本文为u011573853原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。