python中使用多进程multiprocessing并获取子进程的返回值 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 importrandom importtime importmultiprocessing defworker(name, q): t=0 foriinrange(10): print(name+" "+str(i)) ...
importmultiprocessing defworker(name, q): t=0 foriinrange(10): print(name+" "+str(i)) x=random.randint(1,3) t+=x time.sleep(x*0.1) q.put(t) q=multiprocessing.Queue() jobs=[] foriinrange(10): p=multiprocessing.Process(target=worker, args=(str(i), q)) ...