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('不存在,请重新输入!')
  • 相关阅读:
    Java
    oracle与mysql(2)
    oracle与mysql
    junit中的assert方法总结
    java Future用法和意义一句话击破
    Java序列化中的SerialVersionUid
    Nginx了解
    现如今的CDN网站加速技术,细说CDN
    slf4j日志的使用
    IDEA 快捷键整理
  • 原文地址:https://www.cnblogs.com/wzq1997/p/13058256.html
Copyright © 2011-2022 走看看