python中怎么将嵌套列表转为字典?
python中怎么将[["001","小明","98"],["002","小红","88"]]变成[{"学号":"001","姓名":"小明","成绩":"98"},{"...
python中怎么将[["001","小明","98"],["002","小红","88"]]变成
[{"学号":"001","姓名":"小明","成绩":"98"},{"学号":"002","姓名":"小红","成绩":"88"}]
初学小白,求各位大佬指点,要详细代码 展开
[{"学号":"001","姓名":"小明","成绩":"98"},{"学号":"002","姓名":"小红","成绩":"88"}]
初学小白,求各位大佬指点,要详细代码 展开
2个回答
2020-06-06
展开全部
list1=[["001","小明","98"],["002","小红","88"]]
list2=["学号","姓名","成绩"]
list3=[]
for i in range(0,2):
list3.append(dict(zip(list2,list1[i])))
要的东西就在list3里了
list2=["学号","姓名","成绩"]
list3=[]
for i in range(0,2):
list3.append(dict(zip(list2,list1[i])))
要的东西就在list3里了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询