UnicodeDecodeError: 'gbk' codec can't decode byte 0xb5 in position 42: illegal multibyte sequence
时间: 2023-08-14 16:04:31 浏览: 116
basemap readshapefile UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 0-附件资源
这个错误是由于编码问题导致的。根据引用的内容,我可以给出以下解决方法:
1. 在打开文本时,设置正确的编码格式。可以尝试使用utf-8或者gb18030编码格式来打开文件,例如:open('1.txt', encoding='utf-8')或者open('1.txt', encoding='gb18030')。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [UnicodeDecodeError:gbk codec can’t decode byte 0xff in position 0: illegal multibyte sequence](https://blog.csdn.net/qq_40876787/article/details/106739741)[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: 100%"]
[ .reference_list ]
阅读全文