Python - 三级菜单优化方法 (单层循环)
2024-08-28 18:39:12
menu = {
......
}
current_layer = menu
layers = []
while True:
for k in current_layer:
print(k)
choice = input('>:').strip()
if not choice:continue
if choice in current_layer:
layers.append(current_layer)
current_layer = current_layer[choice]
elif choice == 'q':
break
elif choice == 'b':
if len(layers) != 0:
current_layer = layers.pop()
else:
print('-------Top!-------')
最新文章
- [UCSD白板题] Primitive Calculator
- Android工程师常见面试题集答案
- 链接错误-库冲突(libcmt.lib和libcmtd.lib)
- Apache Shiro系列教程之三:Shiro的结构
- ASCII码对照表 (转)
- Filter 过滤器
- 一天一个Java基础——通过异常处理错误
- T-SQL 运行时生成语句
- webrtc学习(二): audio_device之opensles
- protocol buffer的简单使用
- JAVA程序,SESSION没有关闭导致数据库异常
- 16 Socket通信(简单例子)
- leetcode Binary Tree Postorder Traversal python
- JS - 删除确认
- [Ext.Net]TreePanel+gridPanel实例
- java项目中通过添加filter过滤器解决ajax跨域问题
- Mac osx 系统安装 eclipse
- 对Promise的理解?
- 解决Navicat Premium终端操作mysql ONLY_FULL_GROUP_BY错误
- tomcat 启动 关闭 重启脚本
热门文章
- CodeForces 540A Combination Lock (水题)
- OpenCV实现pHash哈希
- GitHub操作总结
- 系统蓝屏stop:ox000007B错误解决方案
- 基于JSP+Servlet开发高校社团管理系统(前台+后台) 源码
- Javascript 链式作用域 function fn(){}和var fn=function(){}区别
- Nutch2.2.1,window,eclipse,安装
- 在 CentOS 上运行 ZKEACMS
- 三张图片看懂ZKEACMS的设计思想
- leetcode 2 两数相加 JAVA