ERROR:root:Error while reading JSON file, terminating: 'gbk' codec can't decode byte 0xa1 in position 2638: illegal multibyte sequence
时间: 2023-10-07 19:07:50 浏览: 141
这个错误是因为在读取json文件时,使用的编码方式是'gbk',但是文件中包含了无法解码的多字节序列。解决这个问题的方法是在打开文件时,指定encoding参数为'utf-8',这样可以确保正确解码文件内容。具体可以使用如下代码:
```python
with open('./统计表分表/data.json', 'r', encoding='utf-8') as f:
data = json.load(f)
print(data)
```
通过这种方式,你可以成功读取并打印出json文件的内容。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Python读取json文件报错“‘gbk‘ codec can‘t decode byte 0x9f in position 26: illegal multibyte ...](https://blog.csdn.net/diana_jiuri1314/article/details/131168225)[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_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [(json型数据读取报错) ‘gbk‘ codec can‘t decode byte 0x80 in position 29: illegal multibyte ...](https://blog.csdn.net/langge_/article/details/124870150)[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_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [oracle 11g rac terminating the instance due to error 481 Doc ID 1383737.1](https://download.csdn.net/download/woshizyq/7584381)[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_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文