在交互模式下,输入help(filter)可以看到这个函数的详细介绍。其中 有 “Return those items of sequence for which function(item) is true.”一句,也就是序列(list,tuple,string)中的每一项作用于函数时,结果为true时就返回。
把第二个参数里的每一项代入lambda
eg:s=1: -1 and 1<0 false 不返回
s=-5: -5 and -5<0 true 返回。
由此可知,最终结果为[-5,-20]。