python-------------三级菜单
来源:互联网 发布:淘宝买近视眼镜靠谱吗 编辑:程序博客网 时间:2024/06/05 20:11
# -*- coding: utf-8 -*-# Author :Gogh# @Time :2017/10/31 15:57# @Email :361910002@qq.com# 三级菜单的操作menu = { '北京': { '海淀': { '五道口': { 'soho': {}, '网易': {}, 'google': {} }, '中关村': { '爱奇艺': {}, '汽车之家': {}, 'youku': {}, }, '上地': { '百度': {}, }, }, '昌平': { '沙河': { '老男孩': {}, '北航': {}, }, '天通苑': {}, '回龙观': {}, }, '朝阳': {}, '东城': {}, }, '上海': { '闵行': { "人民广场": { '炸鸡店': {} } }, '闸北': { '火车战': { '携程': {} } }, '浦东': {}, }, '山东': {},}current_layer = menuparent_layers = [] # 保存所有父级,最后一个元素永远都是父级while True: for k in current_layer: print(k) choice = input(">>>:").strip() if len(choice) == 0: continue if choice in current_layer: parent_layers.append(current_layer) # 在进入下一层之前,把当前层的(也就是下一层父级)追加到列表中 # 下一次loop,当用户选择b的时候,就可以直接取列表最后一个值出来 current_layer = current_layer[choice] # 改成了子层 elif choice == "b": if parent_layers: current_layer = parent_layers.pop() # 取出列表的最后一个值,因为它就是当前层的父级 else: print("无此项!")
阅读全文
0 0
- Python:三级菜单
- Python-三级菜单
- python-三级菜单
- python-------------三级菜单
- Python三级菜单大概思路
- Python练习之三级菜单
- Python下三级菜单实现
- Python笔记(五)三级菜单
- Python三级菜单初学->脑残版
- python三级菜单(优化版)
- Python小程序:三级菜单
- python编程实例-三级菜单
- python中用字典实现三级菜单
- 三级菜单
- 三级菜单
- 三级菜单
- 三级菜单
- 三级菜单
- SRS 代码分析【保存MP3音频文件】
- 从别的机器clone git
- 自定义属性
- RSA加密
- jeecg条件查询出错
- python-------------三级菜单
- java.sql.SQLException:Column Index out of range,0<1
- 猜数字
- cxf+spring自定义restful接口返回消息
- Eureka 源码解析 —— Eureka-Client 初始化(三)之 EurekaClient
- python 虚拟环境[virtualenv/virtualenvwrapper]设置
- android网络之URLconnection
- IIS 7 为 URL Rewrite 模块创建重写规则
- [随笔] 停止mysql正在执行的sql