Python - How to parse JSON string

后端 未结 1 1458
刺人心
刺人心 2021-01-28 21:54

I am trying to find a way to parse a JSON string and save them into mysql. This is my json!

{\"title\": My title, \"desc\": mydesc, \"url\": http//example.com}

1条回答
  •  一个人的身影
    2021-01-28 22:01

    It's unclear from your question what you trying to achieve, but If your question is how to convert JSON to python dict and then load to the table, then that's how you can do it:

    my_dict = json.loads('{"title": "foo", "dest": "bar"}')
    curs.execute('INSERT INTO test (title, dest) values(%(title)s, %(dest)s)', my_dict)
    

    0 讨论(0)
提交回复
热议问题