浅谈python 读excel数值为浮点型的问题
如下所示:
#读入no data = xlrd.open_workbook("no.xlsx") #打开excel table = data.sheet_by_name("Sheet1") #读sheet nrows = table.nrows cols = table.ncols nos = [] for i in range(1,nrows): #指定从1开始,到最后一列,跳过表头 for j in range(cols): ctype = table.cell(i , j).ctype #判断python读取的返回类型 0 --empty,1 --string, 2 --number(都是浮点), 3 --date, 4 --boolean, 5 --error no = table.cell(i, j).value #获取单元格的值 if ctype == 2 : no = str(int(no)) #将浮点转换成整数再转换成字符串 nos.append(no) print(nos)
相关推荐
cmsmdn 2020-04-26
xcguoyu 2019-10-19
xhqiang 2019-06-26
x青年欢乐多 2018-08-04
ddsdevgroup 2013-08-10
LearningMySQL 2019-04-16
pythoning 2019-04-14
iamlazyphper 2014-03-11
yunfeitian 2020-04-18
Accpcjg 2020-02-26
qingsongzdq 2020-02-01
qingsongzdq 2020-01-07
徐建岗网络管理 2019-12-31
ithzhang 2019-12-26
futurezone 2011-06-25
此处省略三千字 2019-06-28