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字典的刪除,修改,添加
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.