pyinstaller UnicodeDecodeError: 'gbk' codec can't decode byte 0x85 in position 1233: illegal multibyte sequence
时间: 2023-10-22 11:28:09 浏览: 58
pyinstaller报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x85 in position 1233: illegal multibyte sequence的原因是在读取文件时使用了错误的编码格式。根据错误信息可以看到是在gbk编码格式下无法解码字节0x85,这是一个非法的多字节序列。解决这个问题的方法是将编码方式改为'utf-8'或'GB18030',或者指定忽略错误,即加上errors='ignore'。例如,可以使用以下方法来解决这个问题:
方法1:with open(file,encoding='utf-8') as f:
方法2:f = open(filename,'r',encoding='GB18030')
方法3:with open(file,'gbk', errors='ignore') as f:
这些方法可以在打开文件时指定正确的编码方式或忽略错误,从而避免UnicodeDecodeError错误的出现。另外,也可以参考字符编码详解的链接,对字符编码有更深入的了解。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Python文件UnicodeDecodeError: invalid start byte / illegal multibyte sequence](https://blog.csdn.net/suoluo_2020/article/details/118387087)[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: 50%"]
- *3* [pyinstaller打包错误 UnicodeDecodeError: 'gbk' codec can't decode byte 0xab in position 160:](https://blog.csdn.net/weixin_42313489/article/details/80470305)[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: 50%"]
[ .reference_list ]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)