首页 > 解决方案 > UnicodeDecodeError:“utf-8”编解码器无法解码字节 0xff

问题描述

我正在尝试使用 python (google colab) 执行读取 csv 的简单过程。

显然我在编码时遇到了错误,我尝试了一些事情,比如添加 enconding = 'utf-8' 和 enconding = 'utf-16' ...但我没有成功。

import pandas as pd
pd.read_csv('/.../data/teste.csv')



UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-18-5726c7261d47> in <module>()
      1 import pandas as pd
----> 2 pd.read_csv('/.../data/teste.csv')

4 frames
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
   1889         kwds["usecols"] = self.usecols
   1890 
-> 1891         self._reader = parsers.TextReader(src, **kwds)
   1892         self.unnamed_cols = self._reader.unnamed_cols
   1893 

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._get_header()

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

标签: pythonpandas

解决方案


推荐阅读