Python 学习之第五天

Posted xmxnx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python 学习之第五天相关的知识,希望对你有一定的参考价值。

列表循环

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 学习之第五天的主要内容,如果未能解决你的问题,请参考以下文章

python学习之第十五天

学Python的第五天

Python面向对象学习之八,装饰器

python学习之第八篇:Python中的函数基础

python学习之第十六课时--缩进(indentation)

python学习之第八课时--for和while循环