码迷,mamicode.com
首页 > 编程语言 > 详细

Python 学习之第五天

时间:2018-05-17 23:18:25      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:lse   第五天   python   打印   输入   nbsp   pre   列表   nic   

列表循环

meun ={
    "北京":{
        "城市一":{
            "县城一":{
                "景点一":{},
                "景点二":{},
                "景点三":{},
            },
            "县城二": {
                "景点一":{},
                "景点二":{},
                "景点三":{},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
        "城市二": {
            "县城一": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城二": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
        "城市三": {
            "县城一": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城二": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
    },
    "上海":{ "城市一":{
            "县城一":{
                "景点一":{},
                "景点二":{},
                "景点三":{},
            },
            "县城二": {
                "景点一":{},
                "景点二":{},
                "景点三":{},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
        "城市二": {
            "县城一": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城二": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
        "城市三": {
            "县城一": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城二": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },},
    "广东":{
        "城市一": {
            "县城一": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城二": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
        "城市二": {
            "县城一": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城二": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
        "城市三": {
            "县城一": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城二": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
            "县城三": {
                "景点一": {},
                "景点二": {},
                "景点三": {},
            },
        },
    },
}  #列表
current_layer   =   meun #列表赋值给变量
# parent_layer    =   meun
parent_layers=[]

while True: #循环
    for a in current_layer: #循环 变量 current_layer 第一层
        print(a)    #打印第一层
    choice=input(">>>:").strip() #用户输入去空格,赋值给变量
    if len(choice) == 0:continue #如果输入的字符取数为空,那么继续循环。
    if  choice in current_layer: #如果输入在的变量的数组里
        # parent_layer    =   current_layer
        parent_layers.append(current_layer)

        current_layer=current_layer[choice] #那么变量取数组中已输入的
    elif    choice=="b":
        if parent_layers:

         current_layer=parent_layers.pop()

    else:
        print("无些项") #否则打印这句

 

 

编码学习

ASCII 码  1个英文或数字,占1个字节。8位

Unicode

 

Python 学习之第五天

标签:lse   第五天   python   打印   输入   nbsp   pre   列表   nic   

原文地址:https://www.cnblogs.com/xmxnx/p/9053621.html

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