UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9d in position 16: invalid start byte
时间: 2023-09-29 08:02:37 浏览: 93
该错误是由于尝试使用UTF-8编解码器解码一个无效的字节序列引起的。在给定的引用中,错误信息指出无法解码位于第16个位置的字节0x9d。这意味着在给定的编码中,0x9d是一个无效的起始字节。要解决这个问题,可以尝试使用其他编解码器进行解码,如gbk。根据给定的引用,可以尝试使用gbk编码器来解码文件,示例如下:
```python
df = pd.read_table(file_name, sep=',', encoding='gbk', error_bad_lines=False, skiprows=[0,2,3], nrows=20000)
```
使用gbk编码器可以解决这个UnicodeDecodeError错误,因为gbk是一种常用的中文编码。<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_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte xx in position xx: invalid continuation byte](https://blog.csdn.net/weixin_43718742/article/details/121992195)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0x9c in position 513: invalid start byte](https://blog.csdn.net/weixin_46713695/article/details/129732050)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文