24 过滤器¶
在函数中设定过滤条件,迭代元素,保留返回值为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]
在函数中设定过滤条件,迭代元素,保留返回值为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]