-2
import time from threading
import thread
def myfunc(i): #Each thread runs this function
print "sleep from thread %d" % i
time. Sleep(5)
print "woke up from thread %d" % i
return
for i in range(10): # Create 10 Thread objects
t = Thread(target=myfunc, args=(i,))
t.start() #Start Each Thread
return
以下のエラーが発生します。あなたが指摘されているエラーのためにPythonでマルチスレッドコードを修正してください
File "threading.py", line 1
import time from threading
^ SyntaxError: invalid syntax
構文は 'from threading import time'です。 – khelwood
D:\ practice_exercise>パイソン トレースバック(最後の最新の呼び出し)threading.py:スレッドインポート時 ファイルから で ファイル "threading.py"、1行目、 "D:\ practice_exercise \ threading.py"、 1行目、 からスレッドをインポートするとき ImportError:名前の時刻をインポートできません –
これは、存在しないものをインポートしようとしていることを意味します。それについて私ができることは何もありません。 – khelwood