Python list to JSON format

CSDN Q & A 2022-01-15 04:25:27 阅读数:390

python list json format

Extract the data from the three lists list=[a,b,c] list2=[1,2,3] list=[4,5,6] To json [{“tiele”:””,”options”:””,”answer”:””},{“tiele”:””,”options”:””,”answer”:””},{“tiele”:””,”options”:””,”answer”:””},{“tiele”:””,”options”:””,”answer”:””},{“tiele”:””,”options”:””,”answer”:””}] In this format




Refer to the answer 1:

I don't quite understand what the relationship is .. such ?

img

list1=['a','b','c'] list2=[1,2,3] list3=[4,5,6] newlist=[]for i in range(len(list1)): item={} item['title']=list1[i] item['options']=list2[i] item['answer']=list3[i] newlist.append(item)print(newlist)



Refer to the answer 2:
版权声明:本文为[CSDN Q & A]所创,转载请带上原文链接,感谢。 https://pythonmana.com/2021/12/202112121916064663.html