三级菜单
程序员文章站
2022-04-15 21:55:36
#! /usr/bin/env python#Version: pyyhon 3.x#Author : Syno''' 1st layer: chinese provinces Anhui 2nd layer: Hefei 3rd layer: Jingkai Area Binghu Area... ......
#! /usr/bin/env python
#version: pyyhon 3.x
#author : syno
'''
1st layer: chinese provinces
anhui
2nd layer:
hefei
3rd layer:
jingkai area
binghu area...
wuhu...
jiangsu...
'''
lab = {'china':
{'shanghai':
{'浦东新区':
['平安镇','大团镇'],
'嘉定区':['华新镇','安亭镇','黄渡镇'],
'闵行区':['北桥镇','新桥镇']},
'jiangsu':
{'najing':
['windows']
,'wuxi':
['linux','else']}},
'usa':
{'newyork':
{'dongcheng':['doc文件']
,'xicheng':['pdf文件','excel文件','其他']},
'califonia':
{'silicon':['1','2']
,'losangles':['3','4']}},
'......':'......'}
'''
print(lab)
print(lab['china'])
print(lab['china']['shanghai'])
print(lab['usa'])
print(lab['usa']['newyork'])
'''
'''while true:
name =input("china or usa?:")
if 'china' ==name:
print("you got china!")
elif 'usa' == name:
print("you got usa!")
elif 'q' == name:
print('bye~')
break
else:
print('invalid input! please try again!')
'''
tip = true
while tip:
for i0 in lab:
print('\t',i0)
in_1st = input('where will you go 1st?>>>')
if in_1st in lab:
while tip:
for i1 in lab[in_1st]:
print('\t',i1)
in_2nd = input('where will you go 2nd?>>>')
if in_2nd in lab[in_1st]:
while tip:
for i2 in lab[in_1st][in_2nd]:
print('\t\t',i2)
in_3rd = input('where will you go 3rd?>>>')
if in_3rd in lab[in_1st][in_2nd]:
while tip:
for i3 in lab[in_1st][in_2nd][in_3rd]:
print('\t\t\t',i3)
in_4th = input('layer above or quit?>>>')
if in_4th == 'b':
break
elif in_4th == 'q':
tip = false
if in_3rd == 'b':
break
elif in_3rd == 'q':
tip = false
if in_2nd == 'b':
break
elif in_2nd == 'q':
tip = false
if in_1st == 'q':
tip = false
推荐阅读
-
Android组件之DrawerLayout实现抽屉菜单
-
想在一个三级城市做一个地方分类信息的网站,该怎么解决
-
excel设置下拉菜单 用PHP实现多级树型菜单
-
Windows 10新版18305推送:沙盒系统上线、开始菜单简化了
-
PHP实现点击导航菜单只改变下面内容模块
-
微信公众平台开发(99) 自定义菜单获取OpenID_PHP教程
-
Android App中DrawerLayout抽屉效果的菜单编写实例,drawerlayout上下抽屉_PHP教程
-
ThinkPHP使用心得分享-ThinkPHP + Ajax 实现2级联动下拉菜单_PHP
-
CSS鼠标悬停下拉菜单演示
-
selenium鼠标悬停显示二级菜单或下拉菜单