首页 > 其他 > 详细

51_work--三级菜单

时间:2017-07-04 10:49:49      阅读:327      评论:0      收藏:0      [点我收藏+]
menu={
    ‘shandong‘:{
        ‘qingdao‘:[‘sifang‘,‘haungdao‘],
        ‘jinan‘:[‘licheng‘,‘zhangqiu‘]
    },
    ‘zhejiang‘:{
        ‘hangzhou‘:[‘xihu‘,‘binjiang‘],
        ‘wnzhou‘:[‘lucheng‘,‘longwan‘]
    },
    ‘guangdong‘:{
        ‘shenzheng‘:[‘futian‘,‘nanshan‘],
        ‘guangzhou‘:[‘zhuhai‘,‘baiyuan‘]
    }
}
flag=True
while flag:
    for i in menu:
        print(i)
    menu1=input(‘Please enter the menu1>>>:‘)
    if menu1 in menu:
        while flag:
            for i1 in menu[menu1]:
                print(i1)
            menu2 = input(‘Please enter the menu2>>>:‘)
            if menu2 in menu[menu1]:
                for i2 in menu[menu1][menu2]:
                    print(i2)
                menu3=input(‘This is the last level menu and press b to return to the previous level >>>:‘)
                if menu3==‘b‘:
                    pass
                elif menu3==‘q‘:
                    flag=False
                else:
                    print(‘The input is incorrect. Please re-enter it‘)
            elif menu2==‘b‘:
                break
            elif menu2==‘q‘:
                flag=False
            else:
                print(‘The input is incorrect. Please re-enter it‘)
    elif menu1 == ‘b‘:
        print(‘The first level menu can not be returned‘)

    elif menu1 == ‘q‘:
        flag = False
    else:
        print(‘The input is incorrect. Please re-enter it‘)

51_work--三级菜单

原文:http://www.cnblogs.com/zy-study/p/7115241.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!