zoukankan      html  css  js  c++  java
  • 字典操作

    #Author:Kevin_hou
    data ={
        "中国":{
            "上海": {
                "浦东": {
                    "曹路":{},
                    "川沙":{},
                    "唐镇":{},
                    "张江":{},
                    "金桥":{},
                    "北蔡":{}
                },
                "黄埔":{},
                "徐汇":{},
                "静安":{}
            },
            "苏州":{
                "吴江":{
                    "松陵":{},
                    "盛泽":{},
                    "同里":{},
                },
                "姑苏":{},
                "吴中":{},
                "工业园":{}
            },
            "宿州":{
                "砀山":{
                    "西南门":{},
                    "梁梨":{},
                    "园艺场":{}
                }
            }
        },
        "日本":{},
        "韩国":{},
        "泰国":{}
     }
    
    exit_flag =False
    while not exit_flag:
        for i in data:
            print(i)
        choice1 = input("进入第一级菜单>>>:")
        if choice1 in data:
            while not exit_flag:
                for i1 in data[choice1]:
                    print("	",i1)
                choice2 = input("进入第二级菜单>>>:")
                if choice2 in data[choice1]:
                    while not exit_flag:
                        for i2 in data[choice1][choice2]:
                            print("		",i2)
                        choice3 = input("进入第三级菜单>>>:")
                        if choice3 in data[choice1][choice2]:
                            while not exit_flag:
                                for i3 in data[choice1][choice2][choice3]:
                                    print("			",i3)
                                choice4 = input("进入最后一层,输入b返回上一层>>>:")
    #                            while not exit_flag:
    #                                print("				",i4)
                                if choice4 =="b":
                                    break
    #                                pass
                                elif choice4 =="q":
                                    exit_flag =True
                        if choice3 =="b":
                            break
                        elif choice3 =="q":
                            exit_flag =True
                if choice2 =="b":
                    break
                elif choice2 == "q":
                    exit_flag =True
    

      

  • 相关阅读:
    jQuery学习笔记01
    webpack概念相关
    vue-cli4 配置公用scss样式的方法
    vue-cli4的路径别名
    webpack学习03——搭建本地服务器
    webpack学习02——Plungin的使用
    VSCode生成vue项目模板
    Vue的使用方法
    webpack学习01——初次打包
    文献随笔目录
  • 原文地址:https://www.cnblogs.com/kevin-hou1991/p/13377852.html
Copyright © 2011-2022 走看看