python json dumps

前端 未结 4 1018
予麋鹿
予麋鹿 2020-12-15 17:46

i have the following string, need to turn it into a list without u\'\':

my_str = \"[{u\'name\': u\'squats\', u\'wrs\': [[u\'99\', 8]], u\'id\': 2}]\"
         


        
4条回答
  •  醉酒成梦
    2020-12-15 18:20

    json.dumps thinks that the " is part of a the string, not part of the json formatting.

    import json
    json.dumps(json.load(str_w_quotes))
    

    should give you:

     [{"id": 2, "name": "squats", "wrs": [["55", 9]]}]
    

提交回复
热议问题