简体   繁体   English

Python XLWT:将列表写入单元格

[英]Python XLWT: Write a list into a cell

I am trying to write a list into a cell using Python XLWT. 我正在尝试使用Python XLWT将列表写入单元格。 Is this possible? 这可能吗?

I am currently getting an error: 我目前收到一个错误:

Exception: Unexpected data type <type 'list'>

The code: 代码:

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

x[1] will be a list. x [1]将是一个列表。

Thanks! 谢谢!

Try converting it to a string first: 首先尝试将其转换为字符串:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM