各位先进达人好,
请问在测试以下程式码为何结果无效?
from multiprocessing import Process, Manager
def f(d):
d[1] += '111'
d['2'] += 222
if __name__ == '__main__':
manager = Manager()
d = manager.dict()
d[1] = '1'
d['2'] = 2
p1 = Process(target=f, args=(d,))
p2 = Process(target=f, args=(d,))
p1.start()
p2.start()
p1.join()
p2.join()
print(d)
以上按照程式逻辑结果print出来是{1: '1', '2': 2}
为什么f()没影响到d这个dict呢?
还请指教
谢谢!