day1_作业2(三级菜单)--改进版

2018-06-18 02:44:22来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

#!/usr/local/bin/python3
# -*- coding:utf-8 -*-
province={
    '江苏省':{
        '南京市':['秦淮区','玄武区','栖霞区'],
        '苏州市':['姑苏区','虎丘区','吴中区'],
        '无锡市':['滨湖区','惠山区','锡山区']
    },
    '浙江省':{
        '杭州市':['西湖区','拱墅区','萧山区'],
        '温州市':['鹿城区','瓯海区','龙湾区'],
        '宁波市':['镇海区','海曙区','江北区']
    }
}
while True:
    print("hello,which province do you want to choose?")
    for i in province:
        print(i)
    province_choose=input("-->")
    while True:
        if province_choose in province.keys():
            print("which city do you want to choose?")
            for j in province[province_choose]:
                print(j)
            city_choose=input("-->")
            while True:
                if city_choose in province[province_choose].keys():
                    print("here are the areas:")
                    for k in province[province_choose][city_choose]:
                        print(k)
                    area_choose=input("-->")
                    while True:
                        if area_choose in province[province_choose][city_choose]:
                            print("there is nothing to show...")
                            break
                        elif area_choose=='q':
                            exit()
                        elif area_choose=='r':
                            break
                        else:
                            print("your choice was unexist!")
                            break
                elif city_choose=='r':
                    break
                elif city_choose=='q':
                    exit()
                else:
                    print("your choice was unexist!")
                    break
                if area_choose=='r':
                    break
        elif province_choose=='q' or province_choose=='r':
            exit()
        else:
            print("your choice was unexist!")
            break
        if city_choose=='r':
            break

  

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Python3爬虫(十四) 验证码处理

下一篇:python中的字符串内置方法小结