python基础教程代码分享

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

people = {
	
	'Alice' : {
		'phone' : '2341',
		'addr' : 'Foo drive 23'
	},

	'Beth' : {
		'phone' : '9102',
		'addr' : 'Bar Street 42'
	},

	'Cecil' : {
		'phone' : '3158',
		'addr' : 'Baz avenue 90'
	}

}

labels = {
	'phone' : 'phone number',
	'addr' : 'address'

}

name = raw_input('Name: ')
request = raw_input('Phone number (p) or address (a)?: ')


if request == 'p' : key = 'phone'
if request == 'a' : key = 'addr'

if name in people : print "%s 's %s is %s ."% \
	(name,labels[key],people[name][key])