当我运行以下代码时,我得到了一个 AttributeError:
#!/usr/bin/env python
import threading
import time
def worker():
for i in range(10):
time.sleep(1) # Seconds
print i
threading.Thread(target=worker).start()
错误:
Traceback (most recent call last):
File "/home/yaa110/workspace/Python27/src/threading.py", line 3, in <module>
import threading
File "/home/yaa110/workspace/Python27/src/threading.py", line 11, in <module>
threading.Thread(target=worker).start()
AttributeError: 'module' object has no attribute 'Thread'
我在 Ubuntu 13.10 上运行 Python 2.7.5。此外,当我通过终端使用 python 时,我通过逐行输入代码没有错误。