zoukankan      html  css  js  c++  java
  • 三层菜单1

    打印省、市、县三级菜单

    可返回上一级

    可随时退出程序

    menu = {
    '北京':{
    '海淀':{
    '清华':{},
    '北大':{}
    },
    '昌平':{
    '沙河':{},
    '天通苑':{},
    '回龙观':{}
    }
    },
    '上海':{
    '闵行':{
    '上海发电机厂':{},
    '上海汽轮机厂':{},
    '上海锅炉厂':{}
    },
    '松江':{
    '东华大学':{
    '教学楼':{},
    '食堂':{},
    '图书馆':{},
    '宿舍':{}
    },
    '上海外国语大学':{},
    '华东政法大学':{}
    },
    '徐汇':{
    '百脑汇':{},
    '上海交通大学':{},
    '铁山家':{}
    }
    },
    '辽宁':{
    '沈阳':{
    '王寅':{},
    '芗芗':{},
    '铁西':{}
    },
    '大连':{
    '大连交通大学':{},
    '大连医科大学':{}
    },
    '朝阳':{
    '二高':{},
    '四中':{},
    '板面':{},
    '灌汤包':{},
    '炖肠':{}
    }
    }
    }

    switch = True
    while switch:
    menu1 = menu

    for key in menu1:
        print(key)
    print('import back to last step,quit to end or choice to next step:')
    
    choice1 = input('1 step:').strip()
    
    if choice1 == 'back':
        break
    if choice1 == 'quit':
        switch = False
        break
    if choice1 not in menu1:
        continue
    
    while switch:
        menu2 = menu1[choice1]
    
        for key in menu2:
            print(key)
        print('import back to last step,quit to end or choice to next step:')
    
        choice2 = input('2 step:').strip()
    
    
        if choice2 == 'back':
            break
        if choice2 == 'quit':
            switch = False
            break
        if choice2 not in menu2:
            continue
    
        while switch:
            menu3 = menu2[choice2]
    
            for key in menu3:
                print(key)
    
            print('import back to last step,quit to end or choice to next step:')
    
            choice3 = input('2 step:').strip()
    
            if choice3 == 'back':
                break
            if choice3 == 'quit':
                switch = False
                break
            if choice3 not in menu3:
                continue
  • 相关阅读:
    CART分类回归树算法
    决策分类树算法之ID3,C4.5算法系列
    break case
    Linux下创建C函数库
    邮件服务
    mysql 语句 GROUP_CONCAT
    python的__mro__与__slot__
    mod_wsgi 的两种模式
    看一看
    【转贴】Linux下MySQL 5.5的修改字符集编码为UTF8(彻底解决中文乱码问题)
  • 原文地址:https://www.cnblogs.com/agsol/p/11515054.html
Copyright © 2011-2022 走看看