#fileName:字符串,Excel文件名称
#workTable:字符串,Excel文件中(sheet)表格名称
def read_excel_data(filePath,workTable):
try:
#这里要用decode,否则中文乱码,读不到文件
dataName = xlrd.open_workbook(filePath.decode('utf8'))
table = dataName.sheet_by_name(workTable.decode('utf8'))
except:
print ('%s文件打开失败'%(filePath))
return table
#读取数据
test_data=read_excel_data('d:\\搜索.xls','搜索')
irows = test_data.nrows
for td in xrange(1,irows):
test_one=test_data.cell(td,0).value #第二行第一列
test_two=test_data.cell(td,1).value #第二行第二列