python 中 map、filter
2020-01-15 11:09
1621 查看
data = [1, 2, 3, 4, 5, 6, 7] result = list(map(lambda x:x%2 == 0, data)) # 计算出结果 [False, True, False, True, False, True, False] result = list(map(lambda x:x*2, data)) # 计算出结果 [2, 4, 6, 8, 10, 12, 14] result = list(filter(lambda x:x%2 == 0, data)) # 过滤原列表 [2, 4, 6] result = list(filter(lambda x:x*2, data)) # 过滤原列表 [1, 2, 3, 4, 5, 6, 7] 非0的int类型都是 True
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- python列表推导 和 内置函数map,filter 效率对比
- Python特殊语法:filter、map、reduce、lambda [转]
- python中高阶函数filter,map,reduce三者的区别
- Python特殊语法:filter、map、reduce、lambda
- 【python】python的内置函数apply()filter() reduce()map()
- Python特殊语法:filter、map、reduce、lambda
- 关于python中,map,reduce,filter,sorted函数的用法
- Python filter,map,lambda,reduce,列表解析
- [Python] 内置序列函数之 filter, map, reduce, zip
- Python特殊语法:filter、map、reduce、lambda [转]
- PythonDay07(进阶)---函数式编程(一):高阶函数、map()函数、reduce()函数、filter()函数、sorted()函数、sort()和sorted()函数的区别
- python中的map,filter,reduce,lambda
- Python filter、map、reduce、lambda
- python常用函数(zip,map,filter,reduce)
- python几个特别函数map filter reduce lambda
- Python基础-map/reduce/filter
- [Python] 函数lambda(), filter(), map(), reduce()
- 零基础入门学习Python(12):lambda表达式、filter()和map()
- python 中的map,dict,lambda,reduce,filter
- Python特殊语法--filter、map、reduce、lambda