Python自学笔记(五)Lambda函数
来源:互联网 发布:python读取ods文件 编辑:程序博客网 时间:2024/05/16 12:08
Lambda函数
简化函数的定义过程
lambda x,y: x+y
使用模块使得小数点不被简化
from _future_ import division
def jia(x,y):
return x+y
def jian(x,y):
return x-y
def cheng(x,y):
return x*y
def chu(x,y):
return x/y
operator = {"+" : jia , "-" :jian , "*" : cheng , "/" , chu}
def f(x,o,y:
print operator.get (o) (x,y,*args,**kwargs)
f(3, "+" , 2)
0 0
- Python自学笔记(五)Lambda函数
- Python自学笔记(四)函数
- Python自学笔记五:单例模式
- python自学笔记(5)--python函数基础
- 【笔记】Python 3自学笔记之函数
- Python学习笔记--匿名函数lambda
- python学习笔记,序列、函数、lambda表达式
- python 3 学习笔记:函数-lambda
- Python 匿名(lambda)函数
- python学习笔记(五)函数
- Python学习笔记(五)函数
- python自学笔记--内嵌函数
- python自学笔记(一)
- python自学笔记(一)
- Python lambda(匿名函数)函数总结
- python自学笔记(6)--Python函数式编程、函数的装饰器、递归
- 自学PHP的笔记(五)
- NRF51822自学笔记(五)蜂鸣器
- PHP 比较操作符
- PHP逻辑操作符
- PHP 运算符 优先级
- PHP 中的feof方法
- PHP iconv方法
- Python自学笔记(五)Lambda函数
- PHP 安全问题
- 有些人有些事
- 【转百度知道】 桌面不显示图标
- 【转】php需要掌握的东西
- RadioButton 文字居中
- PHP 生成excel 时 单元格内换行的问题
- 这两天做项目出现的几个问题
- XP 将 editplus 添加到右键菜单