"""练习题"""cities = { 'Wuhan': { 'country': 'China', 'population': '1700', 'fact': 'nice' }, 'New York':{ 'country': 'America', 'population': '1600', 'fact': 'good' }, 'Paris':{ 'country': 'French', 'population': '1000', 'fact': 'normal
'Wuhan': {
'country': 'China',
'population': '1700',
'fact': 'nice' },
'New York':{
'country': 'America',
'population': '1600',
'fact': 'good'
},
'Paris':{
'country': 'French',
'population': '1000',
'fact': 'normall' }
}
for city_name,city_info in cities.items():
print('city_name:'+city_name)
country = city_info['country']
population = city_info['population']
fact = city_info['fact']
print('country:'+country+'\t'+'population:'+population+'\t'+'fact:'+fact+'\n')
"""添加键和值"""
cities['Wuhan']['history'] = 100
print(cities.items())
"""修改键和值"""
cities['Wuhan']['history'] = 50
print(cities.items())
"""删除键和值"""
del cities['Wuhan']['history']
print(cities.items())