Chapter 6 字典

在字典中储存字典

people = {
    'Joey': {
        'first_name': 'Joey', 
        'last_name': 'Chou', 
        'age': 26, 
        'city':'Shenzhen',
        },
    'Alyx': {
        'first_name': 'Alyx',
        'last_name': 'Lou',
        'age': 28,
        'city': 'Beijing',
    },
    'Daisy': {
        'first_name': 'Daisy',
        'last_name': "Zhang",
        'age': 29,
        'city': 'Shanghai',
    },
}

for friend, info in people.items():
    print("\nFreind's Name :" + friend)
    full_name = info['first_name'] + ' ' + info['last_name']
    age = info['age']
    location = info['city']
        print('\tFull name: ' + full_name )
        print('\tAge :' + str(age))
        print('\tLocation: ' + location ) 
屏幕快照 2019-06-01 下午11.01.53.png

你可能感兴趣的:(Chapter 6 字典)