1 #!/usr/bin/env python
 2 #filter(函数,可以迭代的对象)
 3 
 4 def f1(x):
 5     if x > 22:
 6         return True
 7     else:
 8         return False
 9 
10 
11 ret = filter(f1, [11,22,33,44])
12 #相当于ret = filter(lambda x: x > 22,[11,22,33,44])
13 for i in ret:
14     print(i)

结果:

C:\Python35\python3.exe F:/Python/2day/c1.py
33
44

Process finished with exit code 0

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2021-09-04
  • 2021-12-24
  • 2022-01-12
  • 2021-05-01
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2021-05-06
  • 2023-01-05
  • 2022-01-14
  • 2022-12-23
相关资源
相似解决方案