Read json in python after encoding it

前端 未结 2 1343
南旧
南旧 2021-01-27 17:52

I have a json file that fails loading when I use the following code:

indices_json_path = \'file.json\'
with open(indices_json_path) as json_data:
    d = json.lo         


        
2条回答
  •  花落未央
    2021-01-27 18:08

    I would probably guess it is an encoding error, try:

    import io
    with io.open(indices_json_path,'r',encoding='utf8') as json_data:
        d = json.load(json_data)
    

提交回复
热议问题