filter 过滤

过滤数组中数字为0的

list_x = [1,0,2,0,3,0,4]
r = filter(lambda x: True if x!=0 else False, list_x)
print(list®)
filter过滤
filter的特点:
lambda表达式必须有真和假

相关文章: