UnicodeDecodeError:'utf-8'编解码器无法解码位置35的字节0x96:无效的起始字节 [英] UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 35: invalid start byte
本文介绍了UnicodeDecodeError:'utf-8'编解码器无法解码位置35的字节0x96:无效的起始字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Python的新手,我正在尝试使用以下脚本读取csv文件.
I am new to Python, I am trying to read csv file using below script.
Past=pd.read_csv("C:/Users/Admin/Desktop/Python/Past.csv",encoding='utf-8')
但是,出现错误"UnicodeDecodeError:'utf-8'编解码器无法解码位置35的字节0x96:无效的起始字节",请在此处帮助我了解问题,我在脚本中使用编码以解决错误.
But, getting error "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 35: invalid start byte", Please help me to know issue here, I used encoding in script thought it will resolve error.
推荐答案
发生这种情况是因为您选择了错误的编码.
This happens because you chose the wrong encoding.
如果您使用的是Windows,则只需替换
If you are on Windows just replacing
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')
应该解决问题.
这篇关于UnicodeDecodeError:'utf-8'编解码器无法解码位置35的字节0x96:无效的起始字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文