python-small-examples/md/49.md at master · data-python/python-small-examples

Latest commit

File metadata and controls

16 lines (12 loc) · 279 Bytes

@author jackzhenguo
@desc 
@date 2019/3/4

49 过滤器  

在函数中设定过滤条件,迭代元素,保留返回值为True的元素:

In [1]: fil = filter(lambda x: x>10,[1,11,2,45,7,6,13])

In [2]: list(fil)
Out[2]: [11, 45, 13]