#!/usr/bin/pythonmy_dict = {}options =["A","a","D","d","Q","q"]id = 0while True:print "(A)dd:"print "(D)elete:"print "(Q)uery:"string = raw_input("input your select\n>>>")if string not in options:print "option error !"continueif string == "A" or string == "a":name = raw_input("input your name\n>>>")ID = idid += 1my_dict.update({name:ID})continueif string == "D" or string == "d":name = raw_input("please input the name you want to delete\n>>>")if name not in my_dict:print "sorry , the name not in list"continuemy_dict.pop(name)print "delete %s successfully" % namecontinueif string == "Q" or string== "q":print "1:by name"print "2:by ID"num = raw_input("input your select:")if num != "1" and num!= "2":print "invalid select"if num == "1":for key,ID in sorted(my_dict.iteritems(),key = lambda x:x[0]):print "%s : %d" %(key,ID)else:for key ,ID in sorted(my_dict.iteritems(),key = lambda x:x[1]):print "%s : %d" %(key,ID)