这是代码,encoding='utf-8'
也不起作用:
import pandas as pd
df = pd.read_csv('sunil.csv',encoding ="utf-8")
print(df)
这是错误:
Traceback (most recent call last):
File "C:/Users/ASUS/Desktop/utube/sunil.py", line 2, in <module>
df = pd.read_csv('sunil.csv',encoding ="utf-8")
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\io\parsers.py", line 685, in parser_f
return _read(filepath_or_buffer, kwds)
self._reader = parsers.TextReader(src, **kwds)
File "pandas/_libs/parsers.pyx", line 542, in pandas._libs.parsers.TextReader.__cinit__
File "pandas/_libs/parsers.pyx", line 764, in pandas._libs.parsers.TextReader._get_header
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte
答案 0 :(得分:0)
当我遇到同样的问题时,您能尝试一下对我有用的ISO-8859-1
数据集= pd.read_csv(r'filename.csv',encoding =“ ISO-8859-1”)