错误:
Traceback (most recent call last):
File "son.py", line 120, in <module>
`main()`
File "son.py", line 101, in main
`temp += item`
TypeError: 'ApplyResult' object is not iterable
代码:
pool = multiprocessing.Pool(processes=int(args.process))
for i in range(int(args.process)):
result_first_round.append(pool.apply_async(Son_Algorithm, (i,)))
pool.close()
pool.join()
first_temp = []
for res in result_first_round:
first_temp.append(res)
#first_temp.append(res.get())
#Second Scan
result_final_round = []
temp = []
for item in first_temp:
temp += item
temp2 = []
for result in temp:
if not result in temp2:
temp2.append(result)
temp_result = temp2
答案 0 :(得分:0)
似乎您想将元素item
添加到列表temp
中。在这种情况下,您需要使用方法append()
,如下所示:
temp = []
for item in first_temp:
temp.append(item)
仅当第二个对象也是列表(或至少是可迭代的)时,列表的运算符+=
才起作用。