Python的elif语句
来源:互联网 发布:数据精灵破解版 编辑:程序博客网 时间:2024/05/27 21:06
Python中没有switch/case语句,我们可以用elif语句来模拟它.
如:
if user.cmd == 'create': action = "create item"elif user.cmd == 'delete': action = 'delete item'elif user.cmd == 'update': action = 'update item'else: action = 'invalid choice... try again!'简化一下可以变为如下形式:
if user.cmd in ('create', 'delete', 'update'): action = '%s item' % user.cmdelse: action = 'invalid choice... try again!'使用字典要比使用elif或者for循环快很多.
- Python的elif语句
- Python if elif else语句
- python的elif
- Python-if-elif-else语句
- Python else与elif语句语法讲解
- elif语句
- 2.8 python中的if...elif...else语句 [python入门教程]
- Python 3基础教程8-if elif else语句
- case语句和elif语句
- 【Python】if.. elif..
- python if elif 详解
- python elif用法实战
- Python新手学习基础之条件语句——elif语句
- 关于python中的if-elif-else格式的问题
- python学习2——if语句、elif、if嵌套、while循环、while嵌套
- Python 3从入门到精通6-if,elif,else语句
- Python中elif简单示例
- 【Python-2.7】if-elif-else
- IBM Key Management工具(iKeyMan)脚本吃掉%*$*无法接收命令行参数之解
- 关于几个指针的问题
- uva 10282 - Babelfish
- Bootloader移植简述
- Qt 学习之路 2(3):Hello, world!
- Python的elif语句
- 大数加法模板(c++)
- uboot命令大全 --来源于网络(ChinaUnix)
- PS2接口和协议
- 【Android游戏开发之六】在SurfaceView中添加系统控件,并且相互交互数据!
- vim 插件——浏览器
- NJU2010硕找工作总结
- XCode 4 的调试定位技巧
- 【Android游戏开发之七】(游戏开发中需要的样式)再次剖析游戏开发中对SurfaceView中添加组件方案!