import xlrd, xlwt readbook = xlrd.open_workbook('a.xls') # sheet = readbook.sheet_by_index(1)#索引的方式,从0开始 sheet = readbook.sheet_by_name('使用方法')#名字的方式 nrows = sheet.nrows#行 ncols = sheet.ncols#列 print(nrows) print(ncols) lng = sheet.cell(0,0).value#获取i行3列的表格值 f = open('./out.txt', 'w+') for i in range(14,nrows): for j in range(15,16): index =str(int(sheet.cell(i, 5).value)) data_1 = str(round(sheet.cell(i, 6).value,3) ) data_2 =str(int(sheet.cell(i, 8).value) ) data_3 =str(sheet.cell(i, 10).value) data_4 =str(sheet.cell(i, 11).value) t = index + '~' + data_1 + '~' + data_2 + '~' + data_3 + '~' + data_4 +'\n' f.writelines(t) print(t)