首页 > 代码库 > Python 基础 - Day 1 Practice Example - Three tier menu
Python 基础 - Day 1 Practice Example - Three tier menu
学函数前比较low的版本
data =http://www.mamicode.com/ { ‘北京‘: { ‘海淀‘: { ‘五道口‘: { ‘soho‘: {}, ‘网易‘: {}, ‘Google‘: {}, }, ‘中关村‘: { ‘爱奇艺‘: {}, ‘汽车之家‘: {}, ‘youku‘: {}, }, ‘上地‘: { ‘baidu‘: {}, }, }, ‘昌平‘: { ‘沙河‘: { ‘oldboy‘: {}, ‘北航‘: {}, }, ‘天通苑‘: {}, ‘回龙观‘: {}, }, ‘朝阳‘: {}, ‘东城‘: {}, }, ‘上海‘: { "黄浦": { ‘人民广场‘: { ‘炸鸡店‘: {}, }, }, ‘闸北‘: { ‘火车站‘: { ‘携程‘: {}, }, }, ‘浦东‘: {}, }, ‘山东‘: {}, } exit_flag = False while not exit_flag: for i in data: print(i) # 进入死循环 choice = input("your option >>>:") if choice in data: while not exit_flag: for j in data[choice]: print("\t", j) choice2 = input(‘your 2nd option >>>:‘) while not exit_flag: for k in data[choice][choice2]: print(‘\t\t‘, k) choice3 = input(‘your 3rd option >>>:‘) if choice3 in data[choice][choice2]: for l in data[choice][choice2][choice3]: print(‘\t\t‘, l) choice4 = input("final, please input b for exit") if choice4 == ‘b‘: pass # pass == 啥都不做,必须写否则报错。作为占位符 elif choice4 == "q": exit_flag = True if choice3 == ‘b‘: break elif choice3 == "q": exit_flag = True if choice2 == ‘b‘: break elif choice2 == "q": exit_flag = True
Python 基础 - Day 1 Practice Example - Three tier menu
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。