Python XLWT:将列表写入单元格
我正在尝试用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]将是一个列表。
谢谢!
1 个回答
5
先试着把它转换成字符串:
for x in result:
sheet1.write(row2,0,str(x[0]))
sheet1.write(row2,1,str(x[1]))