D:\Users\Harris\PycharmProjects\pythonProject1\venv\Scripts\python.exe D:/Users/Harris/PycharmProjects/pythonProject1/index.py
Traceback (most recent call last):
File "D:\Users\Harris\PycharmProjects\pythonProject1\index.py", line 3, in <module>
data=xlrd.open_workbook("data1.xlsx")
File "D:\Users\Harris\PycharmProjects\pythonProject1\venv\lib\site-packages\xlrd\__init__.py", line 170, in open_workbook
raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
xlrd.biffh.XLRDError: Excel xlsx file; not supported
进程已结束,退出代码1
原因是最近xlrd更新到了2.0.1版本,只支持.xls文件。所以pandas.read_excel(‘xxx.xlsx’)会报错。
可以安装旧版xlrd,在cmd中运行:
pip uninstall xlrd
pip install xlrd==1.2.0
可以用xlrd3试试
这个只能操作xls 的后缀。 也就是2003版本的excel