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
il jette l'erreur suivante.
Fichier "threading.py", ligne 1
temps d'importation du filetage
^ SyntaxError: syntaxe non valide
Réponses:
0 pour la réponse № 1Pour l’erreur que vous signalez, c’est que l’instruction import devrait ressembler à ceci:
from threading import time