今天利用pd.read_csv(url)从网络上读取数据时出现了如下错误:

'utf-8' codec can't decode byte 0xd0 in position 0

问题原因:网络上的这个文件不是 UTF8 编码的,而系统默认采用 UTF8 解码,用UTF8编解码器无法解码该文件。

但是如果把该文件的编码方式改为UTF8,文件又变成乱码格式,如下:

'utf-8' codec can't decode byte 0xd0 in position 0问题

 

 

解决办法:

新建一个txt文件,把内容复制进去,点击另存为,在编码的地方选择UTF-8,再用pd.read_csv(),完美解决

'utf-8' codec can't decode byte 0xd0 in position 0问题

 

 

备注:sublime text3界面默认是不显示文件编码方式的,如果要想在右下角显示文件编码方式,可以

preference --> settings --> 加入如下代码:

"show_encoding": true,
"show_line_endings": true,

 

相关文章:

  • 2022-12-23
  • 2021-06-11
  • 2021-08-29
  • 2021-09-28
  • 2021-06-26
  • 2021-03-31
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2021-05-22
  • 2021-06-07
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案