请修复python中的多线程代码

时间:2016-08-16 15:41:18

标签: python multithreading python-multithreading

  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

它会抛出以下错误。

  

文件" threading.py",第1行       从线程导入时间
                     ^ SyntaxError:语法无效

1 个答案:

答案 0 :(得分:0)

对于你指出的错误,这是因为import语句应该是这样的:
foreach($secondArray as $key => $value) { $firstArray[$key]['stockQT'] = $value; }