各位前辈们,小弟刚开始学习python,我现在想通过python(我使用的是python2.7)先查找该Excel中的指定名称,再获取该名称对应的数学或者语文成绩,该怎么做呢?
只能循环遍历,或者用odbc数据源当作数据库查询。
循环遍历,找到名称所在的row,然后取row行对应的cloumn的数据。
filepathName = pd.read_excel(filepathName, sep='') #读取表格中数据
ws = wb.worksheets[0] #获取表格中指定工作表
for rx in range(1,ws.max_row+1): #遍历表格中的行数
#print(rx)
temp_list = []
money = ws.cell(row=rx, column=1).value #获取表中第1列所有的数据
kind = ws.cell(row=rx, column=2).value #获取表中第2列所有的数据
temp_list = [money, kind]
data_dic.append(temp_list)
#检测结果
for l in data_dic:
print(l[0],l[1])