小编Has*_*hmi的帖子

多处理 - 无法将列表写入 csv(TypeError:'ApplyResult' 对象不可迭代)

我有一个用于分析大型 csv 文件的脚本,所以我需要启动多处理。我使用了multiprocessing模块并且它工作正常但是如果我尝试将输出列表写入 csv 文件,它会引发错误:

TypeError: 'ApplyResult' object is not iterable
Run Code Online (Sandbox Code Playgroud)

我查找了一些解决方案,包括多处理:TypeError: 'int' object is not iterable but could not solve the problem。这是代码:

from multiprocessing import Pool
import csv
pool = Pool()

nodes = [['1001', '2008-01-06T02:12:13Z', ['']],
        ['1002', '2008-01-06T02:13:55Z', ['']],
        ['1003', '2008-01-06T02:13:00Z',  ['Lion', 'Rhinoceros', 'Leopard', 'Panda']],
        ['1004', '2008-01-06T02:15:20Z', ['Lion', 'Leopard', 'Eagle', 'Panda', 'Tiger']],
        ['1005', '2008-01-06T02:15:48Z', ['Lion', 'Panda', 'Cheetah', 'Goat', 'Tiger']],
        ['1006', '2008-01-06T02:13:30Z', ['']],
        ['1007', '2008-01-06T02:13:38Z', ['Cheetah', 'Tiger', 'Goat']]]

def nodes_to_links(nodes_list):
    output_list = []
    for ii, elem in …
Run Code Online (Sandbox Code Playgroud)

python multiprocessing python-3.x

4
推荐指数
1
解决办法
2588
查看次数

标签 统计

multiprocessing ×1

python ×1

python-3.x ×1