0
我想从已有的列表和字典中制作一个主字典。我很难让它像我认为的那样工作。 我有一个学生姓名列表。从列表和其他字典中嵌套字典
names=[Alice, Bob, Charles, Dan]
我再有2个字典根据学生的身份证号和另一块信息的有信息。
dict1={'100':9, '101:9, '102':11, '103':10} #the keys are student ID and the values are the grade level of the student. Alice is 100, Bob=101...
dict2={'100':9721234567, '101':6071234567, '103': 9727654321, '104':6077654321} #this dictionary gives the home phone number as a value using the student ID as a key.
我该如何制作一本主字典给我所有的学生信息?以下是我在阅读其他问题的答案时所尝试的内容。
Dicta=dict(zip(names, dict1))
Dictb=dict(zip(names, dict2))
Dict=dict(zip(Dicta, Dictb))
下面是我想要得到的答案。
>Dict[Alice]
>>>'100, 9, 9721234567'
#这是Alice的ID,年级和家庭电话