6-1,人
people = {'first_name':'Wang', 'last_name':'Xiaoming', 'age':18, 'city':'Guangzhou'}
for a, b in people.items():
print(a + ':' + str(b))
6-5,河流
rivers = {'Yangtse':'China', 'Ganges':'India', 'Amazon':'Brazil'}
for a,b in rivers.items():
print('The ' + a + ' runs through ' + b)
for river in rivers.keys():
print(river)
for country in rivers.values():
print(country)
6-8,宠物
dog = {'type':'mammalia', 'owner':'xiao ming'}
cat = {'type':'mammalia', 'owner':'xiao hong'}
bird = {'type':'ovipara', 'owner':'xiao wang'}
pets = [dog, cat, bird]
for pet in pets:
for a, b in pet.items():
print(a + ':' + b)
print('\n')
6-8,喜欢的地方
favorite_places = {'xiao ming':['beijing', 'guangzhou'],
'xiao hong':['shanghai', 'xingjiang'],
'xiao wang':['shenzheng', 'wuhan']}
for a,b in favorite_places.items():
print(a + " like to visit ", end='')
for city in b:
print(city + ' ', end='')
print('\n')