python问题:UnicodeDecodeError: 'utf-8' codec can't decode byte in position : invalid start byte

完成机器学习作业时,读取西瓜数据集的.csv文件,发现出现以上错误:UnicodeDecodeError: ‘utf-8’ codec can’t decode byte in position : invalid start byte

看过很多大佬的解决方案都不能搞定,其实问题就是在存在无法进行转换的二进制数据。追其根源,是因为编码方式。
大家只需要修改文件编码方式为UTF-8即可。

步骤:右键选中文件(.csv)------>打开方式:记事本 ------>记事本中另存为 ------>右下角编码方式选择UTF-8
在这里插入图片描述

搞定!

猜你喜欢

转载自blog.csdn.net/weixin_38648232/article/details/85015070