美文网首页
Python内置函数filter()

Python内置函数filter()

作者: 简书冷雨 | 来源:发表于2017-09-15 09:53 被阅读0次

filter(function, iterable)

Construct an iterator from those elements of iterable for which function returns true. iterable may be either a sequence, a container which supports iteration, or an iterator. If function is None
, the identity function is assumed, that is, all elements of iterable that are false are removed.
Note that filter(function, iterable)
is equivalent to the generator expression (item for item in iterable if function(item))
if function is not None
and (item for item in iterable if item)
if function is None
.

相关文章

网友评论

      本文标题:Python内置函数filter()

      本文链接:https://www.haomeiwen.com/subject/ezudsxtx.html