two Lists to Json Format in python

前端 未结 4 729
囚心锁ツ
囚心锁ツ 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:16

    You can combine map with zip.

    jsonized = map(lambda item: {'country':item[0], 'wins':item[1]}, zip(a,b))
    

提交回复
热议问题