尝试读取 2016 版 MS Excel 文件。文件包含多个数据列表。从数据库下载的文件,可以在 MS Office 中正确打开。在下面的示例中,我更改了文件名。
编辑: 文件包含俄语和英语单词。很可能使用了 Latin-1 编码,但 encoding='latin-1'
没有帮助
import pandas as pd
with open('1.xlsx', 'r', encoding='utf8') as f:
data = pd.read_excel(f)
结果:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 14: invalid start byte
没有 encoding ='utf8'
'charmap' codec can't decode byte 0x9d in position 622: character maps to <undefined>
PS Task是处理52个文件,将每个sheet中的数据与52个文件中对应的sheet合并。所以,请不要处理工作建议。
原文由 pure_true 发布,翻译遵循 CC BY-SA 4.0 许可协议
问题很可能出在俄语符号中。
Charmap 是在没有注意到编码的情况下使用的默认解码方法。
如我所见,utf-8 和 latin-1 是否无济于事,然后尝试读取此文件而不是
但
甚至只是
为了检查什么是符号引发异常并删除此符号/符号。