最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

python三级菜单

来源:动视网 责编:小采 时间:2020-11-27 14:28:02
文档

python三级菜单

python三级菜单:menu = { '北京':{ '海淀':{ '五道口':{ 'soho':{}, '网易':{}, 'google':{} }, '中关村':{ '爱奇艺':{}, '汽车之家':{}, 'you
推荐度:
导读python三级菜单:menu = { '北京':{ '海淀':{ '五道口':{ 'soho':{}, '网易':{}, 'google':{} }, '中关村':{ '爱奇艺':{}, '汽车之家':{}, 'you


menu = {
 '北京':{
 '海淀':{
 '五道口':{
 'soho':{},
 '网易':{},
 'google':{}
 },
 '中关村':{
 '爱奇艺':{},
 '汽车之家':{},
 'youku':{},
 },
 '上地':{
 '百度':{},
 },
 },
 '昌平':{
 '沙河':{
 '老男孩':{},
 '北航':{},
 },
 '天通苑':{},
 '回龙观':{},
 },
 '朝阳':{},
 '东城':{},
 },
 '上海':{
 '闵行':{
 "人民广场":{
 '炸鸡店':{}
 }
 },
 '闸北':{
 '火车战':{
 '携程':{}
 }
 },
 '浦东':{},
 },
 '山东':{},
}

二逼青年版:

while True:
 for key in menu:
 print(key)
 choice = input(">>>:")
 if len(choice) == 0: continue
 if choice not in menu:continue
 while True:
 for key2 in menu[choice]:
 print(key2)
 choice2 = input(">>>:")
 if len(choice2) == 0: continue
 if choice2 == "b": break
 if choice2 not in menu[choice]: continue
 while True:
 for key3 in menu[choice][choice2]:
 print(key3)
 choice3 = input(">>>:")
 if len(choice3) == 0: continue
 if choice3 == "b": break
 if choice3 not in menu[choice][choice2]: continue
 while True:
 for key4 in menu[choice][choice2][choice3]:
 print(key4)
 choice4 = input(">>>:")
 if len(choice4) == 0: continue
 if choice4 == "b": break
 if choice4 not in menu[choice][choice2][choice3]: continue

文艺青年版:

current_level = menu
last_level = []
while True:
 for key in current_level:
 print(key)
 choice = input(">>>:")
 if len(choice) == 0:continue
 if choice == "b":
 if not last_level : break
 current_level = last_level[-1]
 last_level.pop()
 if choice not in current_level:continue
 last_level.append(current_level)
 current_level = current_level[choice]

作者:terry
blog:http://www.cnblogs.com/kkterry/
Weibo:http://weibo.com/kkterry
E-mail:doubleginger@163.com
欢迎转载,还请标明出处!多谢多谢!

文档

python三级菜单

python三级菜单:menu = { '北京':{ '海淀':{ '五道口':{ 'soho':{}, '网易':{}, 'google':{} }, '中关村':{ '爱奇艺':{}, '汽车之家':{}, 'you
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top