-
返回filter对象,其中包含对其执行函数时结果为真的所有元素
-
filter(func,sep)
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13def use_filter(l): """ 获取指定列表/元组中的奇数 :param l: list/tuple 要过滤的数据 :return: 过滤好的奇数列表 """ rest = filter(lambda n:n%2 != 0,l) return rest if __name__ == "__main__": l = [1,2,3,4,5,6,7,8,9,10,11] rest = use_filter(l) print(list(rest))
最后
以上就是坚定魔镜最近收集整理的关于python3 filter函数使用的全部内容,更多相关python3内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复