标签:bre pen 山东 城市 inpu 优化 爱奇艺 bsp pre
三级菜单 date = { ‘北京‘: { ‘海淀‘: { ‘五道口‘: { ‘sogo‘: {}, ‘网易‘: {}, ‘google‘: { ‘美女‘: ‘小姐‘, ‘帅哥‘: ‘鸭子‘ } }, ‘中关村‘: { ‘爱奇艺‘: {}, ‘汽车之家‘: {}, ‘youku‘: {}, }, ‘上地‘: { ‘百度‘: {}, }, }, ‘昌平‘: { ‘沙河‘: { ‘汇德商厦老男孩‘: {}, ‘北航‘: {}, }, ‘天通苑‘: {}, ‘回龙观‘: {}, }, ‘朝阳‘: { ‘朝阳大妈‘: {} }, ‘东城‘: {}, }, ‘上海‘: { ‘闵行‘: { "人民广场": { ‘炸鸡店‘: {‘在人民广场吃炸鸡‘: {}} } }, ‘闸北‘: { ‘火车战‘: { ‘携程‘: {} } }, ‘浦东‘: {}, }, ‘山东‘: { ‘高丽‘: {} },} Flag = True while Flag: for key in date: print(key) nun = input(‘请输入城市‘) if nun == ‘q‘: Flag = False if nun == ‘b‘: break if nun in date: while Flag: for i in date[nun]: print(i) nun1 = input(‘请输入‘) if nun1 == ‘b‘: break if nun1 in date[nun]: while Flag: for i1 in date[nun][nun1]: print(i1) nun2 = input(‘请输入‘) if nun2 == ‘b‘: break if nun2 in date[nun][nun1]: while Flag: for i2 in date[nun][nun1][nun2]: print(i2) nun3 = input(‘请输入‘) if nun3 == ‘b‘: break if nun3 in date[nun][nun1][nun2]: while Flag: for i3 in date[nun][nun1][nun2][nun3]: print(nun3) nun4 = input(‘最后一行了,输入b,直接结束‘) if nun4 == ‘b‘: break
三级菜单,优化版 ****************************************************
Flag = True nun = date li = [] while Flag: for key in nun: print(key) in_put = input(‘请输入‘) if in_put in nun: li.append(nun) nun = nun[in_put] if in_put == ‘q‘: li.pop() Flag = False if in_put == ‘b‘: break
标签:bre pen 山东 城市 inpu 优化 爱奇艺 bsp pre
原文地址:https://www.cnblogs.com/python884/p/9860473.html