如何通過Python的多處理將字典傳遞給函數?文檔:https://docs.python.org/3.4/library/multiprocessing.html#reference說,通過一本字典,但我不斷收到Python多處理 - 如何通過kwargs功能?
TypeError: fp() got multiple values for argument 'what'
下面的代碼:
from multiprocessing import Pool, Process, Manager
def fp(name, numList=None, what='no'):
print ('hello %s %s'% (name, what))
numList.append(name+'44')
if __name__ == '__main__':
manager = Manager()
numList = manager.list()
for i in range(10):
keywords = {'what':'yes'}
p = Process(target=fp, args=('bob'+str(i)), kwargs={'what':'yes'})
p.start()
print("Start done")
p.join()
print("Join done")
print (numList)
我認爲[這個線程(http://stackoverflow.com/questions/6832554/python-multiprocessing-how-do-i-share-a-dict-among-multiple-processes)將幫助回答你的問題。 –
也在這裏:https://stackoverflow.com/questions/34031681/passing-kwargs-with-multiprocessing-pool-map –