#!/usr/bin/env python
#filter(函数,可以迭代的对象) def f1(x):
if x > 22:
return True
else:
return False ret = filter(f1, [11,22,33,44])
#相当于ret = filter(lambda x: x > 22,[11,22,33,44])
for i in ret:
print(i)
结果:
C:\Python35\python3.exe F:/Python/2day/c1.py
33
44 Process finished with exit code 0