python读取excel中单元格的内容返回的有5种类型,即上面例子中的ctype:
ctype: 0 empty,1 string, 2 number, 3 date, 4 boolean, 5 error
import xlrd from xlrd import xldate_as_tuple wb = xlrd.open_workbook('data31.xlsx') sh = wb.sheet_by_name('sheet1') for i in range(1, 7): stra_case = sh.cell(i, 1).value index = sh.cell(i, 2).value uiappid = int(sh.cell(i, 3).value) ctype = sh.cell(i, 4).ctype value = sh.cell(i, 4).value a = [] a.append((value, type(value))) print('表格类型:%s' % ctype) print('值和类型%s' % a)
输出结果: