gpt4 book ai didi

python XLWT : Write a list into a cell

转载 作者:太空宇宙 更新时间:2023-11-03 15:25:28 24 4
gpt4 key购买 nike

我正在尝试使用 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] 将是一个列表。

谢谢!

最佳答案

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

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

关于 python XLWT : Write a list into a cell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7747997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com