给定这个嵌套字典,我该如何使用for循环打印所有“ phone”值?
people = {
'Alice': {
'phone': '2341',
'addr': '87 Eastlake Court'
},
'Beth': {
'phone': '9102',
'addr': '563 Hartford Drive'
},
'Randy': {
'phone': '4563',
'addr': '93 SW 43rd'
}
解决方法:
for d in people.values():
print d['phone']