读取excel数据
#coding:utf-8
#导入excel读方法包
import xlrd
#打开excel
excel=xlrd.open_workbook("C:\\Users\\Administrator\\Desktop\\test.xlsx")
#选择Sheet
table=excel.sheet_by_name("Sheet1")
#获取总行数
nrows=table.nrows
#获取总列数
ncols=table.ncols
#读取行数据
#print(table.row_values(0)) #读取行之间数据
#遍历表所有的数据
for i in range(0,ncols+1):
a = table.row_values(i)
print(a)
#读取指定行和列单个数据
print(table.cell_value(0,2))
#读取列之间数据
print(table.col_values(0,2))
参考:https://blog.csdn.net/weixin_43577217/article/details/106717377