【发布时间】:2019-10-16 12:12:01
【问题描述】:
我正在尝试使用具有多个参数的多处理来打印虚拟值,但这似乎不起作用。我收到错误
"f() missing 2 required positional arguments:..."
以下代码:
from multiprocessing import Pool
class tryProcessing:
def f(self, arr, arg1, arg2):
print(arr + " " + arg1 + " " + arg2)
def func(self, arr, arg1, arg2):
arg1 = "hi"
arg2 = "hello"
arr_a = ['1','2']
arr_b = ['3','4','5']
p = Pool(Processes=2)
p.map(self.f, [[a, arg1, arg2], [b, arg1, arg2]])
p.close
我做错了什么?
附: in this answer,他做了类似的事情,我不明白为什么他的作品,而我的没有。
【问题讨论】:
-
参数是否需要在元组中?
[(a, arg1, arg2), (b, arg1, arg2)]
标签: python python-3.x python-multiprocessing