0
我的Python代碼:蟒蛇找不到屬性主題
#!/usr/bin/env python
import threading
from time import sleep,ctime
loops=[4,2]
def loop(nloop,nsec):
print 'start loop',nloop,'at:',ctime()
sleep(nsec)
print 'loop',nloop,'done at:',ctime()
def main():
print 'starting at:',ctime()
threads=[]
nloops = range(len(loops))
for i in nloops:
t = threading.Thread(target = loop, args = (i,loops[i]))
threads.append(t)
for i in nloops:
threads[i].start()
for i in nloops:
threads[i].join()
print 'all Done at:',ctime()
if __name__ == '__main__':
main()
但是Python輸出是:
t = threading.Thread(target = loop, args = (i,loops[i]))
AttributeError: 'module' object has no attribute 'Thread'
Exception AttributeError: '_shutdown' in <module 'threading'
我重新安裝Python,但這個問題還是有,如何解決呢?
專業提示:報告python問題時,始終包含* full * traceback的錯誤。 –