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