Python:函数4——匿名函数和bif:map、filter
来源:互联网 发布:网络平台app代理 编辑:程序博客网 时间:2024/06/05 01:54
匿名函数lambda
>>> g = lambda x: 2 * x + 1>>> g(5)11>>> g = lambda x, y: x + y>>> g(3,4)7好处:1、省定义过程,精简;2、调用次数少,省起名字;3、可读性强,不用跳读
两个牛逼bif
filter()叫做过滤器,把非True的能容过滤掉
help(filter):
filter(function or None, iterable) --> filter object
>>> filter(None, [1, 0, False, True])<filter object at 0x7feed39a6438>>>> list(filter(None, [1, 0, False, True]))[1, True]
>>> def odd(x):... return x % 2... >>> show = filter(odd, range(10))>>> list(show)[1, 3, 5, 7, 9]>>> list(filter(lambda x: x % 2, range(10)))[1, 3, 5, 7, 9]
map()
map(func, *iterables) --> map object把每个iterable的元素都应用func函数返回>>> list(map(lambda x: x * 2, range(10)))[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
0 0
- Python:函数4——匿名函数和bif:map、filter
- BIF:python内置函数
- python中的lambda匿名函数以及针对序列的内建函数map、filter和reduce
- Python闭包函数和一些BIF
- Python——map(),reduce(),filter()函数
- python函数—filter,map,keys
- BIF--filter() 过滤器 和 map()映射
- Python中map,filter和apply函数
- 9.匿名函数:lambda表达式/filter()/map()
- Python函数式编程(高阶函数 <map/reduce filter sorted> 返回函数 匿名函数 装饰器 偏函数)
- python-map()函数,reduce()函数,filter()函数
- python map函数,Filter函数,Reduce函数
- Python内建函数之——filter,map,reduce
- Python内建函数之——filter,map,reduce
- Python内建函数之——filter,map,reduce
- python一些内置函数——filter、map、reduce
- Python高阶函数——map/reduce/filter/sorted
- Python内建函数之——filter,map,reduce
- 使用预编译(PreparedStatement)—— Login 源代码示例
- BCrypt 加密实现
- iOS之CAKeyframeAnimation关键帧动画详解
- Windows上搭建Kafka运行环境
- Servlet中的中文乱码问题
- Python:函数4——匿名函数和bif:map、filter
- c++基础003
- 三大框架路由
- HTML5复习 (14)
- win8 win10 安装msi 提示2502、2503的错误代码
- java里面关键字throws和throw的区别
- matplotlib的基本用法(十三)——figure绘制多图
- Centos7下安装JDK1.7
- #define is unsafe