• Python 练习:三级菜单选择城市


    info = {
        'GuangDong':{
            'GuangZhou': ['TianHe', 'HaiZhu'],
            'MaoMing': ['MaoNan', 'DianBai']},
        'ShanDong': {
            'JiNan': ['ShiZhong', 'LiXia'],
            'QingDao': ['ShiNan', 'ShiBei']
        },
        'GuangXi': {
            'NanNin': ['WuNing', 'LongAn'],
            'GuiLing': ['YangSuo', 'QuanZhou']
        }
    }
    
    flag = True
    
    while flag:
        print(''.center(50, '#'))
        for p in info.keys():
            print("省份:", p)
        province = input("Please input the province: [e : exit]")
        if province == 'e':
            break
        if (province in list(info.keys())) == False:
            print("You need to input right province!")
            continue
        while True:
            print(''.center(50, '#'))
            for c in info[province].keys():
                print("城市: ", c)
            city = input("Please input the city: [q: return; e: exit]")
            if city == 'q':
                break
            if city == 'e':
                flag = False
                break
            if (city in list(info[province].keys())) == False:
                print("You need to input right city!")
                continue
            for k in info[province][city]:
                print("区县: ", k)
    

    运行结果:

  • 相关阅读:
    IfcDirection
    IfcPcurve
    IfcOffsetCurve3D
    IfcOffsetCurve2D
    IfcLine
    IfcEllipse
    IfcCircle
    IfcConic
    IfcTrimmedCurve
    QDockWidget设置为tab切换形式
  • 原文地址:https://www.cnblogs.com/klvchen/p/8646466.html
Copyright © 2020-2023  润新知