Python利用字典实现switch功能
来源:互联网 发布:淘宝设置不包邮地区 编辑:程序博客网 时间:2024/06/06 17:24
利用字典实现switch功能
#!/usr/bin/python# -*- coding:UTF-8 -*-from __future__ import division#利用字典实现switch功能#实现加减乘除的功能def add(x,y): return x + ydef substract(x,y): return x - ydef multiply(x,y): return x * ydef divide(x,y): return x / yoperator = {"+":add,"-":substract,"*":multiply,"/":divide}def switch(x,o,y): return operator.get(o)(x,y)print switch(3,'+',2)
阅读全文
0 0
- Python利用字典实现switch功能
- Python利用字典实现switch功能
- python之 利用字典与函数实现switch case功能
- python字典实现switch功能
- 使用Python函数和字典实现Java中的switch功能
- python实现switch功能
- Python利用dict实现switch
- python实现类似switch功能
- python dict 实现 switch 功能
- Python中实现switch功能
- python字典 switch语句
- python学习总结---switch功能实现
- python实现简单的switch功能
- 利用Python实现多线程聊天功能
- python通过字典实现java的switch-case模式匹配(代码有注释)
- python switch的实现
- python中实现switch
- Python的switch实现
- hdu2660
- git add 与 git commit
- Android studio 依赖冲突的解决
- python 列表字符串字典
- 解决Eclipse Debug 的source not found问题
- Python利用字典实现switch功能
- Django-路由系统
- 【知识库】--spring ApplicationContext 加载配置文件 refresh()(241)
- Head First设计模式--第一章-策略模式
- 【Tensorflow】怎样为你的网络预加工和打包训练数据?(二):小数据集的处理方案
- redis之key、string、list、set、sort set、hash、精细持久化、snapshotting快照保存、主从模式
- Android学习之Service(上)
- Python日期与字符串互转
- Struts2笔记01 Struts2中filter有无ng