• 三级菜单(基础版)


    #__author:"SongZhiXue"
    #date: 2018/6/2 0002
    
    
    menu = {
        '北京':{
            '朝阳':{
                '国贸':{
                    'CICC':{},
                    'HP':{},
                    '渣打银行':{},
                    'CCTV':{},
                },
                '望京':{
                    '陌陌':{},
                    '奔驰':{},
                    '360':{},
                },
                '三里屯':{
                    '优衣库':{},
                    'apple':{},
                },
            },
            '昌平':{
                '沙河':{
                    '老男孩':{},
                    '阿泰包子':{},
                },
                '天通苑':{
                    '链家':{},
                    '我爱我家':{},
                },
                '回龙观':{},
            },
            '海淀':{
                '五道口':{
                    '谷歌':{},
                    '网易':{},
                    '搜狐':{},
                    '搜狗':{},
                    '快手':{},
                },
                '中关村':{
                    '优酷':{},
                    '爱奇艺':{},
                    '汽车之家':{},
                    '新东方':{},
                    '腾讯':{},
                },
            },
        },
        '上海':{
            '浦东':{
                '陆家嘴':{
                    'CICC':{},
                    '高盛':{},
                    '摩根':{},
                },
                '外滩':{},
            },
            '闵行':{},
            '静安':{},
        },
        '山东':{
            '济南':{},
            '青岛':{},
            '德州':{
                '乐陵':{
                    '丁务镇':{},
                    '城区':{},
                },
                '平原县':{},
            },
        },
    }
    back_flag = False
    exit_flag = False
    while not back_flag and not exit_flag:
        for key in menu:
            print(key)
        choice1 = input('1>>>:').strip()
        if choice1 in menu:
            while not back_flag and not exit_flag:   #让程序停在第二层
                for key2 in menu[choice1]:
                    print(key2)
                choice2 = input('2>>>:').strip()
                if choice2 == 'b':
                    back_flag = True
                if choice2 == 'q':
                    exit_flag = True
                if choice2 in menu[choice1]:
                    while not back_flag and not exit_flag:
                        for key3 in menu[choice1][choice2]:
                            print(key3)
                        choice3 = input('3>>>:').strip()
                        if choice3 == 'b':
                            back_flag = True
                        if choice3 == 'q':
                            exit_flag = True
                        if choice3 in menu[choice1][choice2]:
                            while not back_flag and not exit_flag:
                                for key4 in menu[choice1][choice2][choice3]:
                                    print(key4)
                                choice4 = input('4>>>:').strip()
                                print('最后一层')
                                if choice4 == 'b':
                                    back_flag = True
                                if choice4 == 'q':
                                    exit_flag = True
                            else:
                                back_flag = False
                    else:
                            back_flag = False
            else:
                    back_flag = False
  • 相关阅读:
    在当前的webview中跳转到新的url 使用WebView组件显示网页
    android WebView中js的alert()失效
    移动平台的WebApp之Meta标签
    CSS背景属性Background详解
    JS仿淘宝左侧菜单
    什么是 Backbone.js
    mssql Row_Number() 分页 DISTINCT 问题
    跟我一起玩转Sencha Touch 移动 WebApp 开发(一)
    HTML5 book响应式翻页效果
    HTML5开发的翻页效果实例
  • 原文地址:https://www.cnblogs.com/songzhixue/p/9124679.html
Copyright © 2020-2023  润新知