小编pur*_*rue的帖子

熊猫读取_excel:'utf-8'编解码器无法解码位置14的字节0xa8:无效的起始字节

试图读取MS Excel文件,版本2016。文件包含带有数据的多个列表。从数据库下载的文件,可以在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)
Run Code Online (Sandbox Code Playgroud)

结果:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 14: invalid start byte
Run Code Online (Sandbox Code Playgroud)

不带 encoding ='utf8'

'charmap' codec can't decode byte 0x9d in position 622: character maps to <undefined>
Run Code Online (Sandbox Code Playgroud)

PS任务是处理52个文件,将每张纸中的数据与52个文件中的对应纸合并。因此,请不要处理任何工作建议。

python excel pandas

5
推荐指数
3
解决办法
3106
查看次数

标签 统计

excel ×1

pandas ×1

python ×1