使用xlrd读取xlsx文件时,会报错:XLRDError: Excel xlsx file; not supported
from xlrd import open_workbook
th = open_workbook(r'文件.xlsx')
是因为新版的xlrd不支持xlsx文件,只支持xls文件,xlrd 已删除了对 xls 文件以外的任何内容的支持。
1.如果想要使用xlrd读取xlsx文件,需要安装旧版xlrd
pip install xlrd==1.2.0
但是这种方法会遇到一些其他的问题,会有安全警告,并且在读取excel文件时会报错:
AttributeError: 'ElementTree' object has no attribute 'getiterator'
该类报错是因为在新版python3.9中,windows中使用的更新删除了getiterator

最低0.47元/天 解锁文章
4万+

被折叠的 条评论
为什么被折叠?



