标签:turn 循环 退出 ret 不为 老男孩 nbsp rip 执行
menu = { ‘北京‘: { ‘海淀‘: { ‘五道口‘: { ‘soho‘: {}, ‘网易‘: {}, ‘google‘: {} }, ‘中关村‘: { ‘爱奇艺‘: {}, ‘汽车之家‘: {}, ‘youku‘: {}, }, ‘上地‘: { ‘百度‘: {}, }, }, ‘昌平‘: { ‘沙河‘: { ‘老男孩‘: {}, ‘北航‘: {}, }, ‘天通苑‘: {}, ‘回龙观‘: {}, }, ‘朝阳‘: {}, ‘东城‘: {}, }, ‘上海‘: { ‘闵行‘: { "人民广场": { ‘炸鸡店‘: {} } }, ‘闸北‘: { ‘火车战‘: { ‘携程‘: {} } }, ‘浦东‘: {}, }, ‘山东‘: {}, } def threeLM(dic): while True: for k in dic:print(k) key = input(‘input>>‘).strip() if key == ‘b‘ or key == ‘q‘:return key # 输入b会return b本身,直接结束当前循环,返回上一级,不断输入b,直至结束 elif key in dic.keys() and dic[key]: # 判断key在列表中,并且有内容不为空,则进行递归执行下一步 ret = threeLM(dic[key]) if ret == ‘q‘: return ‘q‘ #如果输入q,则直接退出 threeLM(menu)
标签:turn 循环 退出 ret 不为 老男孩 nbsp rip 执行
原文地址:https://www.cnblogs.com/wzc27229/p/11116258.html