[terry笔记]python三级菜单
把三级菜单输出,选择后逐层显示,”b“返回上一级菜单。
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笔记]python三级菜单的更多相关文章
- python三级菜单实例(傻瓜版和进阶版)
程序: python三级菜单 要求: : 1.打印省.市.县三级菜单 2.可返回上一级 3.可随时退出程序 方案一:傻瓜版(其实傻瓜版考察的主要是思路!思路清楚了,那才不是傻瓜!O(∩_∩)O哈哈~) ...
- python(5)- 简单练习:python三级菜单优化
python三级菜单优化,菜鸟版链接:http://www.cnblogs.com/xuyaping/p/6648170.html menu = { '北京':{ '海淀':{ '五道口':{ 'so ...
- python三级菜单的实现
一.作业要求 1.使用字典实现三级菜单功能 2.直接输入前面数字进入下一级菜单 3.按B返回上一级,按Q退出 二.需要知识点 1.if循环 2.for循环,enumerate的用法 3.while循环 ...
- python 三级菜单 while循环三次,湖北省市-县-街道的选择,3个while的循环 -day2
python编写一个三级while的循环菜单 1.定义字典,字典里面嵌套字典,内嵌字典的值为列表. 思路: 湖北省的市:字典中的定义3个字典,用于存储{序列-键:市名} shiqu_dir = {} ...
- Python 三级菜单 增强版
需要实现的功能是:三级菜单1.从文本内读出选项2.查询每一级的选项,并能对选项进行增/删/改功能3.每一级可以退出程序或者返回上一层 2018-5-14 更新内容 思路 实现过程中的BUG及解决方案: ...
- python三级菜单
#-*- coding:utf-8 -*-#Author:gxli #一级菜单项def menu(): #遍历字典dic一级菜单 print('-----------一级菜单------------- ...
- Python 三级菜单与优化(一层循环嵌套)
优化的思路是使用单层循环嵌套完成三级菜单,这个优化思路我非常喜欢,我喜欢在编程的时候用最少的东西写出同样的效果,通常这样会绕来绕去,但非常有趣!!! 需求: 1.运行程序输出第一级菜单: 2.选择一级 ...
- Python——三级菜单
#三级菜单函数 menu = { '北京':{ 海淀:{ '五道口':{} '中关村':{} '上帝':{} } '昌平':{} '朝阳':{} '东城':{} }, '上海':{} '山东':{} ...
- 4th,Python三级菜单
1. 运行程序输出第一级菜单 2. 选择一级菜单某项,输出二级菜单,同理输出三级菜单 3. 菜单数据保存在文件中 4. 让用户选择是否要退出 5. 有返回上一级菜单的功能 data = { '北京': ...
随机推荐
- redis_ 5 集群
[转自 ]https://www.cnblogs.com/hjwublog/p/5681700.html#_label0 Redis集群简介 Redis 集群是3.0之后才引入的,在3.0之前,使用哨 ...
- 腾讯云 ubuntuservermysql安装和外网訪问
1 腾讯云 购买ubuntu 默认账户是ubuntu(因为winscp 使用ubuntu没有权限写文件) 因为腾讯云主机ubuntu系统默认username为ubuntu,不喜欢每次做什么都要sudo ...
- iframe显示滚动栏
子页面通过iframe载入.出现了竖向滚动栏 最后查出原因:文档申明 iframe有滚动栏的页面的文档申明 <!DOCTYPE html> 改成例如以下即可了 <!DOCTYPE H ...
- 【C++】String类中的运算符重载
模块化设计: 头文件: <span style="font-size:18px;"> #ifndef operator_operator_h #define opera ...
- 自己动手写CPU之第七阶段(6)——乘累加指令实现思路
将陆续上传本人写的新书<自己动手写CPU>.今天是第29篇.我尽量每周四篇 亚马逊的销售地址例如以下,欢迎大家围观呵! http://www.amazon.cn/dp/b00mqkrlg8 ...
- 一个JavaWeb项目中使用的部分技术
-- 2015年8月8日 1. Web框架: Spring+ SpringMVC + MyBatis Spring: 作为容器.工厂,用于解耦以及管理对象生命周期. 整合各类框架和依赖. MVC : ...
- elasticsearch源码分析之search模块(client端)
elasticsearch源码分析之search模块(client端) 注意,我这里所说的都是通过rest api来做的搜索,所以对于接收到请求的节点,我姑且将之称之为client端,其主要的功能我们 ...
- 对于NAS,IP SAN以及iSCSCI SAN存储的一些认识和理解
一直以来用户对于在选购存储产品上有许多不清楚,市场上有NAS, FC SAN,IP SAN和iSCSCI SAN产品,到底哪种类型的产品更适合支撑企业的应用系统呢? 我们经常可以听到用户讲: “NAS ...
- 关于QObject类的一些理解
QRunnable并没有继承自QObject,所以它和其他QObject组件的通信不能使用传统的信号和槽,要是用信号和槽我们必须将其继承自QObject自动的添加 QThread的退出最好用exit( ...
- Binary Indexed Tree 总结
特点 1. 针对 数组连续子序列累加和 问题(需要进行频繁的 update.sum 操作): 2. 并非是树型结构,只是逻辑上层次分明: 3. 可以通过 填坑法 来理解: 4. 中心思想:每一个整数都 ...