zoukankan      html  css  js  c++  java
  • 字典三级菜单(查看子菜单及返回上级退出)

    实现内容:

         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
     
    
    
  • 相关阅读:
    手机的基本功能测试情景模式
    C#.net技术内幕04集合
    .net 发送电子邮件
    SQL:select case when(转)
    《 C#技术内幕》学习01IDisposable
    C#.net技术内幕03字符串
    点击确定后页面跳转
    SQL注入式攻击
    C#.NET技术内幕 02表达式
    window xp自带的功能之繁体字
  • 原文地址:https://www.cnblogs.com/zhangwy1024/p/10235157.html
Copyright © 2011-2022 走看看