UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 7837: illegal multibyte sequence
时间: 2023-09-25 18:14:50 浏览: 122
invalid multibyte character sequence 870告警1
在这个问题中,出现了UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 7837: illegal multibyte sequence的错误。这个错误的原因是Python的编码方式取决于平台。如果是Windows平台,默认编码是gbk。如果文件是utf8编码,就会出现这个错误。解决这个问题的方法是在打开文件时指定正确的编码方式。比如可以使用`with open(f_path, 'r',encoding='utf-8') as f:`来打开文件并指定使用utf-8编码。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xad in position 110: illegal multibyte ...](https://blog.csdn.net/qq_16792139/article/details/124152710)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [报错UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xad in position 47: illegal multibyte ...](https://blog.csdn.net/Liquor6/article/details/120782193)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xad in position 2: illegal multibyte sequence](https://blog.csdn.net/weixin_47295886/article/details/125203449)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文