filter() 函数 判断数组里面的 数据 是否符合 要求,符合就加入数组

参考: https://www.runoob.com/python/python-func-filter.html

 

 有可能输出有问题 最后输出改成 print( list(newlist) )

 

其他例子(判断变量是否为空):

a=3
b=4

print (list(filter(lambda X: True if X else False, [a,b,C])))

posted @ 2020-05-14 22:45  凯宾斯基  阅读(495)  评论(0编辑  收藏  举报