代码如下
people={
'Alice':{
'phone':'2341',
'addr':'Foo drive 23'
},
'Beth':{
'phone':'9102',
'addr':'Bar street 42'
},
'Cecil':{
'phone':'3158',
'addr':'Baz avenue 90'
}
}
labels={
'phone':'phone number',
'addr':'address'
}
name=raw_input('Name:')
if request == 'p':key = 'phone'
if request == 'a':key = 'addr'
if name in people:
print("%s's %s is %s. " % \ (name, labels[key], people[name][key]))
我检查了几遍都没有发现问题在哪里,求大神指出
转载于:https://blog.51cto.com/13594217/2068018