赞
踩
- #6-1 人
- message={'first_name':'xiao','last_name':'ming',
- 'age':'18','city':'beijing'}
- print(message['first_name'])
- print(message['last_name'])
- print(message['age'])
- print(message['city'])
-
- #6-2 喜欢的数字
- message={'a':'7','b':'1','c':'3','d':'8','e':'9'}
- print(message['a'])
- print(message['b'])
- print(message['c'])
- print(message['d'])
- print(message['e'])
-
- #6-3 词汇表
- cihuibiao={'#':'注释','list':'list'}
- print('#'+':'+cihuibiao['#']+'\n')
- print('list'+':'+cihuibiao['list']+'\n')
-
- #6-4 词汇表2
-
- #6-5 河流
- rivers={
- 'Rhine':'Switzerland',
- 'changJiang':'china',
- 'nile':'egypt',
- }
- for river,country in rivers.items():
- print('The '+river.title()+'runs through the '+country.title()+'.')
-
- #6-7 人
- people={
- 'name_1':{
- 'first':'xiao',
- 'last':'ming',
- 'city':'beijing'
- },
- 'name_2':{
- 'first':'zhang',
- 'last':'san',
- 'city':'xian',
- }
- }
- for username,user in people.items():
- print("用户:"+username)
- name=user['first']+" "+user['last']
- city=user['city']
- print("全名:"+name.title()+" 住址:"+city.title())
-
- #6-8 宠物
- pets={
- 'pet_1':{
- 'pet_name':'lunlun',
- 'classify':'dog',
- 'master':'zi',
- },
- 'pet_2':{
- 'pet_name':'aoao',
- 'classify':'cat',
- 'master':'yang',
- }
- }
- for key,value in pets.items():
- print(key.title()+"的名字是:"+value['pet_name'].title()+
- ",它是只"+value['classify']+",它的主人是:"+value['master'])
-
- #6-9 喜欢的地方
- favorite_places={
- 'man_1':'beijing',
- 'man_2':'yunnan',
- 'man_3':'sanya',
- }
- for key,value in favorite_places.items():
- print(key.title()+"最喜欢的地方是"+value.title())
-
- #6-10 喜欢的数字
- favorite_numbers={
- 'a':'3,7',
- 'b':'1,9',
- 'c':'0',
- }
- for key,value in favorite_numbers.items():
- print(key.title()+"喜欢的数字是"+value.title())
-
- #6-11 城市
- cities={
- 'sanya':{'country':'china','population':'14','fact':'hot'},
- 'newyork':{'country':'america','population':'3','fact':'hot'},
- }
- for key,value in cities.items():
- print(key.title()+"属于"+value['country']+",这个国家有"+
- value['population']+"亿人,这个城市"+value['fact'])
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。