码迷,mamicode.com
首页 > 其他好文 > 详细

【代码段】-- 三级菜单 (基础版)

时间:2017-08-24 11:32:11      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:菜单   als   author   color   least   man   for   false   log   

# __author__:"ShengXin"
# __date__:2017/8/24
full_menu = {河北省:{张家口市:[蔚县,涿鹿县,怀来县,阳原县],
                        唐山市:[丰润区,滦县,开平区,玉田县],
                        衡水市:[武邑县,武强县,枣强县,市辖区]
                        },
             山西省:{太原市:[A,B,C,D],
                        大同市:[AA,BB,CC,DD],
                        吕梁市:[AAA,BBB,CCC,DDD]
                        },
             河南省:{郑州市:[W,E,R,T],
                        开封市:[WW,EE,RR,TT],
                        洛阳市:[WWW,EEE,RRR,TTT]
                         }
             }
town = []
county = []
flag_one = True
while flag_one:
    flag_two = True
    print("欢迎来到德莱联盟,请选择您想加入的省:".center(30,"-"))
    for i in full_menu:   #遍历键
        print(i)
    choose = input("您选择:")
    if choose in full_menu:
        while flag_two:
            print("%s".center(30,"-")%choose)
            for j in full_menu[choose]:  #市区
                print(j)
                town.append(j)
            flag_two = True
            flag_three =True
            small_choose = input("选择您感兴趣的市,b返回,q退出")
            if small_choose in town:
                while flag_three:
                    print("%s".center(30,"-")%small_choose)
                    hah = ((full_menu[choose])[small_choose])
                    for e in hah:
                        print(e)
                        county.append(e)
                    flag_three =True
                    flag_four = True
                    least_choose = input("请选择您喜欢的县,b返回,q退出")
                    if least_choose in county:
                        while flag_four:
                            flag_four =True
                            print("\n"+least_choose+"欢迎您")
                            man = input("您可按b继续选择县,按q选择市,按w退出")
                            if man == "b":
                                flag_four =False
                            elif man == "q":
                                flag_four = False
                                flag_three = False
                            elif man == "w":
                                flag_four = False
                                flag_three = False
                                flag_two = False
                    if least_choose == "b":
                        break
                    elif least_choose == "q":
                        flag_two =False
                        break
                    elif least_choose == "w":
                        flag_one =False
                        flag_two =False
                        break
            elif small_choose == "b":
                break
            elif small_choose == "q":
                flag_two = False
            else:
                print("请重新输入,或按b返回")
    elif choose == "q":
        print("再见")
        flag_one = False
    else:
         print("请重新输入,或按q退出")

 

【代码段】-- 三级菜单 (基础版)

标签:菜单   als   author   color   least   man   for   false   log   

原文地址:http://www.cnblogs.com/SHENGXIN/p/7422073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!