/usr/local/bin/python2.7 "/Volumes/NO NAME/work/djangorestful_hui-master/tutorial/threading.py"
Traceback (most recent call last):
File "/Volumes/NO NAME/work/djangorestful_test-master/tutorial/threading.py", line 3, in <module>
import threading
File "/Volumes/NO NAME/work/djangorestful_test-master/tutorial/threading.py", line 14, in <module>
t1 = threading.Thread(target=music, args=('爱的故事', 3))
AttributeError: 'module' object has no attribute 'Thread'
Process finished with exit code 1
名字叫threading.py,在程序中使用了threading.Thread,报错。
原因是自己编写的文件和系统中的文件名重名,优先使用了自己写的threading文件。
更换文件名为:threadingDemo.py。
运行成功,建议在取名时,大家尽量不要使用系统关键字。
本文介绍了一次因Python脚本中文件命名不当导致的错误,具体表现为与系统内置的threading模块名称冲突,通过更改自定义文件名解决了该问题。
1293

被折叠的 条评论
为什么被折叠?



