E:\anaconda\ruanjianbenti\python.exe C:\Users\WHliGONG\Desktop\shuxuejianmo\随机森林.py Traceback (most recent call last): File "C:\Users\WHliGONG\Desktop\shuxuejianmo\随机森林.py", line 3, in <module> df=pd.read_csv("C:\\Users\\WHliGONG\\Desktop\\tempdanti.xlsx") File "E:\anaconda\ruanjianbenti\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper return func(*args, **kwargs) File "E:\anaconda\ruanjianbenti\lib\site-packages\pandas\io\parsers\readers.py", line 678, in read_csv return _read(filepath_or_buffer, kwds) File "E:\anaconda\ruanjianbenti\lib\site-packages\pandas\io\parsers\readers.py", line 575, in _read parser = TextFileReader(filepath_or_buffer, **kwds) File "E:\anaconda\ruanjianbenti\lib\site-packages\pandas\io\parsers\readers.py", line 932, in __init__ self._engine = self._make_engine(f, self.engine) File "E:\anaconda\ruanjianbenti\lib\site-packages\pandas\io\parsers\readers.py", line 1234, in _make_engine return mapping[engine](f, **self.options) File "E:\anaconda\ruanjianbenti\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 75, in __init__ self._reader = parsers.TextReader(src, **kwds) File "pandas\_libs\parsers.pyx", line 544, in pandas._libs.parsers.TextReader.__cinit__ File "pandas\_libs\parsers.pyx", line 633, in pandas._libs.parsers.TextReader._get_header File "pandas\_libs\parsers.pyx", line 847, in pandas._libs.parsers.TextReader._tokenize_rows File "pandas\_libs\parsers.pyx", line 1952, in pandas._libs.parsers.raise_parser_error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 14: invalid start byte 进程已结束,退出代码1 这个报错怎么解决
时间: 2023-07-06 14:33:25 浏览: 95
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这个报错是因为在读取Excel文件时,使用了错误的编码方式。建议你尝试使用正确的编码方式来读取Excel文件,例如:
```
df=pd.read_excel("C:\\Users\\WHliGONG\\Desktop\\tempdanti.xlsx", encoding='gbk')
```
如果你还是无法解决问题,可以尝试使用其他的编码方式进行读取。
阅读全文