python-filter函数
2020-12-13 02:55
标签:迭代器 false int 保存 turn 过滤 documents 调用 library filter与lambda结合使用 python-filter函数 标签:迭代器 false int 保存 turn 过滤 documents 调用 library 原文地址:https://www.cnblogs.com/xiaokuangnvhai/p/11062090.htmldef add(a):
return a%2==0
print(list(filter(add,[1,2,3,4])))
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 /Users/dongyf/Documents/python/besttest_study/cnz/ycc/a.py
[2, 4]
stu_score = {‘xiaobai‘:50,‘xiaohei‘:30,‘xiaolan‘:80,‘xiaojun‘:100,
‘xiaoming‘:60}
result=filter(lambda score:score>60,stu_score.values())
print(list(result))
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 /Users/dongyf/Documents/python/besttest_study/cnz/ycc/a.py
[80, 100]
上一篇:Java中的线程--线程中的工具