dic={ '植物': {"草本植物": ['牵牛花','刮花距','葫芦'], '水生植物': ['乔木','杉'] }, '动物': {'两栖动物': ['山鬼'] } } # li = [] # go = True # # for v in enumerate(dic,1): # print(v) # #li.append(v) # print(li) # while go: # for i,v in enumerate(dir,1): # print(i,v) # li.append() # v_c=str(input('>>>')) # if v_c.isdigit(): # pass # elif v_c.isalpha(): # v_c=v_c.lower() # if v_c==i: # lx=input('类型:') # if dic.get(lx,1)==1: # dic[lx]={} # # zl= input('种类:') # if dic.get(lx[zl],1)==1: # dic[lx][zl]=[] # mc=input('名称:') db={ '北京': { '昌平': { '沙河':{}, '回龙观':{}, }, '西郊':{}, '朝阳':{} }, '上海': { } } # q=input(">>>") # db[q]={} # print(db) path=[] while True: temp = db for item in path: temp=temp[item] print("当前可选的所有节点",list(temp.keys())) choice=input('1.添加节点;2.查看节点(Q/B);\n>>>') if choice == '1': name=input("输入要添加的节点名称") temp[name]={} elif choice == '2': name=input("输入你想要查看的节点名称:") path.append(name) elif choice.lower() == 'b': path.pop() elif choice.lower() == 'q': break else: print("输入错误,重新输入") # while True: # chose=input('1.添加节点;2.查看节点(Q/B);\n>>>') # if chose=='1': # pass # elif chose==2: # pass # elif chose.lower()==b: # pass # elif # # print('全部的节点',db.keys())
day13字典的删除,修改,添加
猜你喜欢
转载自blog.csdn.net/qq_37311616/article/details/80317958
今日推荐
周排行