zoukankan      html  css  js  c++  java
  • 三级菜单

    # coding:utf-8
    menu = {
    '北京':{
    '海淀':{
    '五道口':{
    'soho':{},
    '网易':{},
    'google':{}
    },
    '中关村':{
    '爱奇艺':{},
    '汽车之家':{},
    'youku':{},
    },
    '上地':{
    '百度':{},
    },
    },
    '昌平':{
    '沙河':{
    '老男孩':{},
    '北航':{},
    },
    '天通苑':{},
    '回龙观':{},
    },
    '朝阳':{},
    '东城':{},
    },
    '上海':{
    '闵行':{
    "人民广场":{
    '炸鸡店':{}
    }
    },
    '闸北':{
    '火车站':{
    '携程':{}
    }
    },
    '浦东':{},
    },
    '山东':{},
    }
    current_layer = menu
    layers = []
    while True:
    for i in current_layer:
    print(i)
    choice = input('输入>>:').strip()
    print('返回上一层按b,退出按q')
    if not choice:continue
    if choice in current_layer:
    layers.append(current_layer)
    current_layer = current_layer[choice]
    elif choice == 'b':
    if len(layers) != 0:
    current_layer = layers.pop()
    else:
    print('已经是最后一层了哦!')
    elif choice == 'q':
    exit('再见!')
    else:
    print('不存在,请重新输入!')
  • 相关阅读:
    Samba服务器配置
    Showdoc
    wkhtmltoimage(网页剪切功能)
    GTID数据库备份
    awstats日志分析
    docker桥接
    php的opcache缓存扩展(php页面代码刷新速度)
    Pureftp SSL/TLS配置
    ssh-keygen配置
    systemctl使用
  • 原文地址:https://www.cnblogs.com/wzq1997/p/13058256.html
Copyright © 2011-2022 走看看