Filter(函数,可以迭代的对象)
循环可以迭代的对象,获取每一个参数,函数(参数)
def f1(x):
return True
filter(f1,[11,22,33,44])

def f1(x):
if x % 2 == 0:
return True
else:
return False
ret = list(filter(f1, [11, 22, 33, 44]))
print(ret)
ret2 = list(filter(lambda x: x % 2 == 0, [11, 22, 33, 44, 55, 66, ]))
print(ret2)
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\python.exe “C:\Program Files\JetBrains\PyCharm 2017.2\helpers\pydev\pydevd.py” –multiproc –qt-support=auto –client 127.0.0.1 –port 10054 –file C:/Users/Administrator/PycharmProjects/py/filter_test.py
pydev debugger: process 892 is connecting
Connected to pydev debugger (build 172.3317.103)
[22, 44]
[22, 44, 66]
Process finished with exit code 0