• 字典三级菜单(查看子菜单及返回上级退出)


    实现内容:

         1.可以进入子菜单

         2.可以返回上一级

         3.可以从任意一级直接退出

    dic = {
        "植物":
            {"草本植物":["风信子", "牵牛花", "紫罗兰", "牡丹", "向日葵"],
             "木本植物": ["乔木", "半乔木", "灌木", "如松", "", ""],
             "水生植物": ["荷花", "风信子", "马蹄莲", "睡莲", "水仙", "满江红"]},
        "动物":
            {"两栖动物":["青蛙", "蜥蜴", "娃娃鱼", "", "", "鳄鱼", "山龟"],
             "禽类":["", "鸭子", "", "斗鸡", "长尾鸡", "鸽子"],
             "哺乳类动物":["", "", "", "", "老虎", "豹子", "斑马"]}
    }
    li = []
    go = True
    while go:
    for i,v in enumerate(dic,1):
    li.append(v)
    print(i,v)

    u_c = input(">>>")
    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 = str(input(">>>"))
    if u_c1.isdigit():
    u_c1 = int(u_c1)
    elif u_c1.isalpha():
    u_c1 == u_c1.lower()
    if u_c1 == "b":
    li1.clear() # 或者用 del li1[:]
    break
    elif u_c1 == "q":
    go = False
    break
    while go:
    for i in dic[li[u_c-1]][li1[u_c1-1]]:
    print(i)
    u_c2 = str(input(">>>"))
    u_c2 = u_c2.lower()
    if u_c2 == "b":
    li1.clear() #或者用 del li1[:]
    break
    elif u_c2 == "q":
    go = False
    break
     
    
    
  • 相关阅读:
    Out of hay
    P3028 [USACO10OCT]汽水机Soda Machine
    P3619 魔法
    P2847 [USACO16DEC]Moocast(gold)奶牛广播-金
    P2830 写程序
    c#DateTime与unix时间戳互相转换
    C# UdpClient使用
    udp单播,广播,多播实现(ReceiveFromAsync,SendToAsync)
    udp广播,单播,多播
    C#实现异步阻塞TCP(Send,Receive,Accept,Connect)
  • 原文地址:https://www.cnblogs.com/zhangwy1024/p/10235157.html
Copyright © 2020-2023  润新知