python_day9 共享数据
from multiprocessing import Manager,Process
import time
import os
def work(l,d):
l.append(os.getpid())
d[os.getpid()]=os.getpid()
if __name__ == '__main__':
m=Manager()
l=m.list()
d=m.dict()
p_l=[]
for i in range(5):
p=Process(target=work,args=(l,d))
p_l.append(p)
p.start()
for p in p_l:
p.join()
print(l)
print(d)
print('主进程')