two Lists to Json Format in python

前端 未结 4 741
囚心锁ツ
囚心锁ツ 2020-12-09 19:56

I have two lists

a=[\"USA\",\"France\",\"Italy\"]
b=[\"10\",\"5\",\"6\"]

I want the end result to be in json like this.

[{\         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 20:09

    In addition to the answer of 'falsetru' if you need an actual json object (and not only a string with the structure of a json) you can use json.loads() and use as parameter the string that json.dumps() outputs.

提交回复
热议问题