UnicodeDecodeError: 'gbk' codec can't decode byte 0xa0 in position 1677: illegal multibyte sequence
时间: 2023-10-18 19:29:02 浏览: 114
关于GBK和Unicode字符集转换乱码问题
3星 · 编辑精心推荐
您遇到的错误是UnicodeDecodeError: 'gbk'编解码器无法解码字节0xa0,不合法的多字节序列。这个错误通常在读取本地HTML文件或yaml文件时出现。解决这个问题的方法是在读取文件的相关代码中添加encoding='UTF-8'参数。例如,在使用pyquery库读取本地HTML文件时,可以将代码修改为:open('filename.html', 'r', encoding='UTF-8')。同样地,在读取yaml文件时也可以添加相同的参数。这样就能够正确地解码文件中的内容,避免出现编码错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [pyquery报错:UnicodeDecodeError: ‘gbk’ codec can’t decode byte](https://download.csdn.net/download/weixin_38665944/13751270)[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%"]
- *2* *3* [UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xa7 in position 265: illegal multibyte ...](https://blog.csdn.net/qq_44368508/article/details/126831706)[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 ]
阅读全文