标签: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
标签:lse 第五天 python 打印 输入 nbsp pre 列表 nic
原文地址:https://www.cnblogs.com/xmxnx/p/9053621.html