Python高阶函数filter的用法

来源:互联网 发布:网络信息安全的公司 编辑:程序博客网 时间:2024/04/28 20:59

filter在英语里的意思正是过滤,那我们看看在Python3中filter如何使用?
下面是filter函数的__doc__,说的就是根据根据function把可迭代对象(iterable)筛选一下,过滤出迭代器。

    filter(function or None, iterable) --> filter object    Return an iterator yielding those items of iterable for which function(item)    is true. If function is None, return the items that are true.

举个例子:
example

原创粉丝点击