三级子目录建立

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("请输入子节点名称 ")
        if name in temp:
            print("节点存在")
        else:
            temp[name] = {}
    elif choice == "2":
        name  = input("请输入要查看的节点名称:\n>>>")
        path.append(name)
    elif choice.lower() == "b":
        if path:
            path.pop()
    elif choice.lower() == "q":
        break
    else:
        print("输入错误请重新输入")

 

posted @ 2018-04-16 13:29  夏天的麦田  阅读(229)  评论(0编辑  收藏  举报