python JSON object must be str, bytes or bytearray, not 'dict

后端 未结 3 1285
梦如初夏
梦如初夏 2020-12-07 17:29

In Python 3, to load json previously saved like this:

json.dumps(dictionary)

the output is something like

{\"(\'Hello\',)\": 6, \"

3条回答
  •  一个人的身影
    2020-12-07 17:57

    import json
    data = json.load(open('/Users/laxmanjeergal/Desktop/json.json'))
    jtopy=json.dumps(data) #json.dumps take a dictionary as input and returns a string as output.
    dict_json=json.loads(jtopy) # json.loads take a string as input and returns a dictionary as output.
    print(dict_json["shipments"])
    

提交回复
热议问题