UnicodeDecodeError: 'gbk' codec can't decode byte 0xa0 in position 220: illegal multibyte sequence
时间: 2023-10-18 10:26:34 浏览: 127
Python运行报错UnicodeDecodeError的解决方法
当你在使用pyquery库读取本地HTML文件时,出现了UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position 164: illegal multibyte sequence的错误。这个错误通常是由于文件的编码格式与你的脚本解码方式不匹配所导致的。解决这个问题的方法是在读取文件的相关代码中加入encoding='UTF-8'参数,指定文件的编码格式为UTF-8。这样,你的脚本就能正确解码文件中的内容了。<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 ]
阅读全文