#simple database#peoplepeople = { 'Alice':{ 'phone':'2341', 'addr':'Foo drive 23' }, 'Beth':{ 'phone':'9102', 'addr':'Bar street 42' }, 'Ceil':{ 'phone':'3158', 'addr':'Baz avenue 90' }}#describelabels = { 'phone':'phone number', 'addr':'address'}name = raw_input('Name:')request = raw_input('Phone number (p) or adress (a)?')#find phone or addressif request == 'p':key = 'phone'if request == 'a':key = 'address'if name in people: print "%s's %s is %s." % (name,labels[key],people[name][key])
简单的数据库
python version 2.4.3