标签:request address python 程序 number
python 学习了好久,发现还是个小白,python还是不会用,从今天起每天学写一点小程序,做个打不死的小强。
相关知识:列表,字典
#!/usr/bin/env python
people = {
‘yong‘:{‘phone‘:‘123‘,
‘addr‘:‘Shang hai‘
},
‘bu‘:{‘phone‘:‘456‘,
‘addr‘:‘Wu han‘
},
‘yan‘:{‘phone‘:‘789‘,
‘addr‘:‘He nan‘
}
}
lables = {‘phone‘:‘phone number: ‘,
‘addr‘:‘address :‘
}
name = raw_input("Please input you name: ")
request = raw_input("Please input a(address) or p(phone) :")
if request == ‘a‘:key=‘addr‘
if request == ‘p‘:key=‘phone‘
if name in people:
print "%s‘s %s is %s" % \
(name,lables[key],people[name][key])
标签:request address python 程序 number
原文地址:http://lengku.blog.51cto.com/4965809/1533442