这里将queue作为中间通道进行数据传递,queue是线程和进程安全的
from multiprocessing import process, queuedef f(q): q.put([42, none, 'hello'])if __name__ == '__main__': q = queue() p = process(target=f, args=(q,)) p.start() print q.get() # prints [42, none, 'hello'] p.join()
希望本文所述对大家的python程序设计有所帮助。
