原代码如下
myfile="C:\文件\industry.xls"
data = xlrd.open_workbook(myfile)
table = data.sheets()[0]
ncols=table.ncols
nrows = table.nrows
mylist = []
for j in range(nrows):
for i in range(1, ncols): # 因为第1列的‘1’是序号,不计算在内
myCell = table.cell(j, i)
myCellValue = myCell.value
if myCellValue==1:
biaoti=table.cell(0, i).value
BIAOTI=str(biaoti)
BIAOTI1=BIAOTI.replace('第7题(',' ')
BIAOTI2 = BIAOTI1.replace(')', ' ')
mylist.append(BIAOTI2)
print(mylist)
得到的结果是:
但我要的只是最后一排的那个列表