欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

三级菜单

程序员文章站 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