UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 3561: invalid start byte
时间: 2023-10-16 08:10:11 浏览: 192
这个错误表示在解码时遇到了无效的字节。具体来说,在位置3561处,字节0xb9无法由utf-8编码解码。这通常是因为被读取的文件不是采用utf-8编码的。
解决这个问题的方法是更改读取文件时的编码格式。常用的编码格式有ascii, gb18030, gbk和gb2312。你可以尝试使用这些编码格式来解决这个错误。例如,你可以使用gb18030编码格式来读取文件:
```python
stock = pd.read_csv(r'文件路径', encoding="gb18030")
```
通过将编码格式更改为适合你的文件的编码格式,你应该能够成功读取文件而不产生UnicodeDecodeError错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 2: invalid continuation byte-...](https://download.csdn.net/download/weixin_42204453/15589184)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [报错:UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xb0 in position 2: invalid start byte](https://blog.csdn.net/m0_56230003/article/details/130326974)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文