操作方法
首先,需要安装xlrd(pip install xlrd即可)。
xlrd中,通过.open_workbook('文件名')来打开工作簿; 通过.sheet_by_name('sheet名')或.sheets()[编号]来引用到sheet,注意,编号从0开始; 通过.cell(行号,列号).value来引用单元格的值,行号和列号编号均从0开始,比如,a4单元格表示为cell(0,3)。
示例: import xlrd bok = xlrd.open_workbook(r'D:\python_codes\output.xlsx') sht = bok.sheets()[0] row1 = sht.row_values(0) cell_d4 = sht.cell(3,3).value