【发布时间】:2021-07-28 12:53:17
【问题描述】:
我想通过将列表映射到字典来创建新字典,因此列表项将是键,字典将是值。
学生名单:
[Student1,Student2,Student3]
字典:
{Math:90, CS:94, Since:89}
预期结果是一本字典:
{
"Student1":{
Math:90
},
"Student2":{
CS:94
},
"Student3":{
Since:89
}
}
我托盘这个:
new_dic=dic()
new_dic = dic(zip(students,dic1)
输出: { 学生1:数学, 学生2:CS, 学生3:自从 }
但它给了我意想不到的结果。我也尝试了here 的解决方案,但它对我不起作用。
【问题讨论】:
标签: python dictionary