#一个令人cao蛋的查询题目:
# li = []
# go = True
# while go:
# for i,v in enumerate(dic,1):
# print(i,v)
# li.append(v)
# u_c = str(input(">>>1,2,查看,i添加"))#1
# if u_c.isdigit():
# u_c = int(u_c)
# li1 = []
# while go:
# for i,v in enumerate(dic[li[u_c-1]],1):
# print(i,v)
# li1.append(v)
# u_c1 = input(">>>>")
# u_c1 = int(u_c1)
# while go:
# for i in dic[li[u_c-1]][li1[u_c1-1]]:
# print(i)
# # v = input("请输入")
# u_c5 = str(input(">>>>>q,退出,b返回"))
# u_c5 = u_c5.lower()
# if u_c5 == "b":
# li1.clear()
# # del li1[:]
# break
# elif u_c5 == "q":
# go = False
# break
# elif u_c.isalpha():
# u_c == u_c.lower()
# if u_c == "i":
# lx = input("类型:")
# if dic.get(lx,1) == 1:
# dic[lx] = {}
# zl = input("种类:")
# if dic[lx].get(zl,1) == 1:
# dic[lx][zl] = []
# while True:
# mc = input("名称:")
# if mc == "q":
# li.clear()#一进程序打印第一次,返回的时候clear
# break
# if mc in dic[lx][zl]:
# print("fuck")
# else:
# dic[lx][zl].append(mc)
# db = {
# "北京":{
# "昌平":{
# "沙河":{},
# "回龙观":{}
# },
# "朝阳":{},
# "海淀":{}
# },
# "上海":{}
# }
# path = []
# while True:
# temp = db
# for item in path:
# temp = temp[item]
# print("节点:",list(temp.keys()))
# # db[input(">>>")] = {}
# # print(db)
# u_c = input("1,添加,2,查看,(b,q),退出,返回>>>")
# if u_c == ‘1‘:
# name = input("请添加>>>")
# temp[name] = {}
# elif u_c == ‘2‘:
# name = input("查看>>>")
# path.append(name)
# elif u_c.lower() == ‘b‘:
# if path:
# path.pop()
# elif u_c.lower() == ‘q‘:
# break
# else:
# print("Error")
# db = {
# "北京":{
# "昌平":{
# "沙河":{},
# "回龙观":{}
# },
# "朝阳":{},
# "海淀":{}
# },
# "上海":{}
# }
# path = []
# while True:
# temp = db
# for item in path:
# temp = temp[item]
# print(list(temp.keys()))
# u_c = input("1添加,2查看,(b,q)返回,退出>>>")
# if u_c == ‘1‘:
# v = input("请添加节点>>>>")
# if v in temp:
# print("节点以存在")
# else:
# temp[v] = {}
# elif u_c == ‘2‘:
# v = input("请输入查看节点>>>>")
# if v in temp:
# path.append(v)
# else:
# print("不存在该节点")
# elif u_c.lower() == ‘b‘:
# path.pop()
# elif u_c.lower() == ‘q‘:
# break
# else:
# print("Error")
原文:https://www.cnblogs.com/Edendd/p/14034361.html