#(1)导入模块xlrd
import xlrd
#(2)打开工作薄book
wb = xlrd.open_workbook('../Stu_pack/school.xls')
#(3)根据工作薄中的工作表
sheet = wb.sheet_by_index(0)
#(4)根据行列序号读取内容并存放到二维列表里面
schools = [] #定义一个二维列表存放工作表数据
for row in range(sheet.nrows):
school = [] #定义一个一维列表存放每个单元格的数据
for col in range(sheet.ncols):
content = sheet.cell_value(row,col)# 读取每个单元格的数据存放到变量content里面
school.append(content) #将每行的数据追加到一维列表school里面
schools.append(school) #将每行的数据追加到二维列表school里面
#(5)读取二维列表里的数据前十项数据(包括列表名称共十一行):
for school in schools[:11]:
print(school)
import pandas as pd
pd.read_excel('../Stu_pack/school.xls')