这是我的代码:
#--coding:utf-8--
import sys
sys.path.append('D:\\python2.7.11\\xlrd-1.0.0')
from xlrd import open_workbook
wb = open_workbook('file0.xls')
for s in wb.sheets():
print 'Sheet:',s.name
for row in range(s.nrows):
values=[]
for col in range(s.ncols):
values.append(s.cell(row,col).value)
print ','.join(values)
print
这是我的结果:
===================== RESTART: D:\python2.7.11\test_0.py =====================
Sheet: 实验分组
组内序号,姓名,学号,班级,电话,组内分工比例
Traceback (most recent call last):
File "D:\python2.7.11\test_0.py", line 13, in <module>
print ','.join(values)
TypeError: sequence item 3: expected string or Unicode, float found
我该如何解决这个问题?在我的file0.xls中,第二行是数字而不是unicode。