from multiprocessing import Process, Pipe
def f(conn):
conn.send('Hello World!') #向管道中发送数据
conn.close()
if __name__ == '__main__':
conn_A, conn_B = Pipe() #创建管道对象
p = Process(target=f, args=(conn_A,)) #将管道的一方给子进程
p.start()
p.join()
print("Received message:",conn_B.recv()) #通过管道的另一方获取数据
Python使用管道实现进程间数据传递
猜你喜欢
转载自blog.csdn.net/weixin_43873198/article/details/107574258
今日推荐
周排行