3

我正在尝试使用 Python XLWT 将列表写入单元格。这可能吗?

我目前收到一个错误:

Exception: Unexpected data type <type 'list'>

编码:

    for x in result:
        sheet1.write(row2,0,x[0])
        sheet1.write(row2,1,x[1])

x[1] 将是一个列表。

谢谢!

4

1 回答 1

5

尝试先将其转换为字符串:

for x in result:
    sheet1.write(row2,0,str(x[0]))
    sheet1.write(row2,1,str(x[1]))
于 2011-10-13T00:13:40.083 回答