#coding:gbk#6-7人
Taylor ={'first_name':'Taylor','last_name':'Swift','age':30,'city':'Nashville',}
Avirl ={'first_name':'Avirl','last_name':'Lavigne','age':36,'city':'Toronto',}
Skylar ={'first_name':'Skylar','last_name':'Gray','age':27,'city':'New York',}
people =[Taylor,Avirl,Skylar]for person in people:print(person)#6-8宠物
dog ={'kind':'dog','owner':'a',}
cat ={'kind':'cat','owner':'b',}
bird ={'bird':'bird','owner':'c',}
pets =[dog,cat,bird]for pet in pets:print(pet)#6-9喜欢的地方
favorite_places ={'a':'New York','b':['Paris','Marselli'],'c':['LA','Toronto','Melborn'],}for name,place in favorite_places.items():print(name.title()+"'s favorite place is:")print(place)#此处想要做出制表符美化输出,但是发现在value为列表的情况下,无法通过在前添加制表符实现空格,后尝试直接插入空格发现不论是制表符还是直接插入,都无法在列表前加入空格#6-10喜欢的数字
favorite_numbers ={'a':1,'b':[1,2,3],'c':[3,4],'d':[4,5],'e':[5,6,7,8],}for name,number in favorite_numbers.items():print(name.title()+"'s favorite numbers are:")print(number)#6-11城市
cities ={'NY':{'country':'US','population':1,'fact':'prosperous',},'Paris':{'country':'France','population':2,'fact':'luxury',},'Amoy':{'country':'China','population':3,'fact':'green',}}for city,info in cities.items():print("\nCity: "+ city)
pop = info['population']
fac = info['fact']print("\tPopulation:"+str(pop))print("\tFact:"+ fac.title())#6-12扩展#略