在python中加载json文件

with open(file,"r") as f:
  data = json.load(f)

如果报错

UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte

 

将with open(file) as f: 改成 with open(file, 'r', encoding='utf-8') as f

 

来源:http://www.shanhubei.com/archives/2426.html

posted @ 2022-10-21 14:29  珊瑚贝博客  阅读(59)  评论(0编辑  收藏  举报