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])))

猜你喜欢

转载自www.cnblogs.com/kaibindirver/p/12891894.html