当前位置: 首页 > 面试题库 >

UnicodeDecodeError:'utf-8'编解码器无法解码位置35的字节0x96:无效的起始字节

祁英哲
2023-03-14
问题内容

我是Python的新手,正在尝试使用以下脚本读取csv文件。

Past=pd.read_csv("C:/Users/Admin/Desktop/Python/Past.csv",encoding='utf-8')

但是,出现错误“
UnicodeDecodeError:’utf-8’编解码器无法解码位置35处的字节0x96:无效的起始字节”,请在此帮助我了解问题,我在脚本中使用编码认为可以解决错误。


问题答案:

发生这种情况是因为您选择了错误的编码。

由于您使用的是Windows计算机,因此只需更换

Past=pd.read_csv("C:/Users/Admin/Desktop/Python/Past.csv",encoding='utf-8')

Past=pd.read_csv("C:/Users/Admin/Desktop/Python/Past.csv",encoding='cp1252')

应该解决问题。



 类似资料: