问题
I am trying to write a list into a cell using 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.
Thanks!
回答1:
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]))
来源:https://stackoverflow.com/questions/7747997/python-xlwt-write-a-list-into-a-cell