UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 24: invalid continuation byte
时间: 2023-08-02 21:07:10 浏览: 61
引用\[1\]:错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 13: invalid continuation byte 。 引用\[2\]:参考网址:python 导入数据错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 0: invalid start_计算法的博客-CSDN博客。 引用\[3\]:采用utf-8解码就会报错,可以使用GBK或者是“unicode_escape”进行解码 reserve = conn.recv(10000).decode() #linux # reserve = conn.recv(10000).decode("unicode_escape") #windows 中文 # reserve = conn.recv(10000).decode("GBK") # windows 中文 。
问题:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 24: invalid continuation byte
回答: 这个错误是由于在使用utf-8解码时遇到了无效的续字节导致的。解决这个问题的方法是使用其他编码方式进行解码,如GBK或者"unicode_escape"。你可以尝试使用以下代码进行解码:
reserve = conn.recv(10000).decode("GBK") # windows 中文
或者
reserve = conn.recv(10000).decode("unicode_escape") #windows 中文
这样就可以避免UnicodeDecodeError错误的出现。
#### 引用[.reference_title]
- *1* *2* *3* [UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xc5 in position 13: invalid continuation ...](https://blog.csdn.net/devil8123665/article/details/125156027)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)