创建一个名为cities 的字典,其中将三个城市名用作键;对于每座城市,都创建一个字典,并在其中包含该城市所属的国家、人口约数以及一个有关该 城市的事实。在表示每座城市的字典中,应包含country 、population 和fact 等键。将每座城市的名字以及有关它们的信息都打印出来。
cities = {
'luo yang': {'country': 'China', 'population': '14 hundred millions', 'fact': 'mu dan'},
'cheng du': {'country': 'China', 'population': '14 hundred millions', 'fact': 'panda'},
'xia men': {'country': 'China', 'population': '14 hundred millions', 'fact': 'gu lang yu'},
}
for city_name, city_inf in cities.items():
country = city_inf['country']
populatin = city_inf['population']
fact = city_inf['fact']
print(city_name.title()+":")
print("\tcounty:"+country)
print("\tpopulation:"+populatin)
print("\tfact:"+fact)
print('\n')