【Python】xlrd模块
xlrd模块介绍
- xlrd是读取excel表格数据
- 支持xlsx和xls格式的excel表格
- 安装方式:pip3 install xlrd
- 模块导入方式:import xlrd
Excel读取 xlrd
- 打开Excel
- xlsx=xlrd.open_workbook('文件地址')
- 找到Sheet
- table=xlsx.sheet_by_name('表名')
- table=xlsx.sheet_by_index('表序号')
- 根据行列读取内容
- table.cell_value(行,列)
- table.cell(行,列).value
- table.row(行)[列].value
常见问题
- 在PyCharm中调用xlrd模块出现 ModuleNotFoundError: No module
- 原因是在PyCharm中未加载xlrd
- pycharm--文件--设置--项目--Python解释器--软件包--“+”添加xlrd
- 读取xlsx文件时报错:xlrd.biffh.XLRDError: Excel xlsx file; not supported
- 原因是最新的xlrd居然不支持Excel xlsx文件的读取。
- 解决办法: 卸载最新的xlrd库,安装历史版本的xlrd库。pip3 install xlrd ==1.2.0
THE END
0
二维码
打赏
海报


【Python】xlrd模块
xlrd模块介绍
xlrd是读取excel表格数据支持xlsx和xls格式的excel表格安装方式:pip3 install xlrd模块导入方式:import xlrd
Excel读取 xlrd
打开……
