python基础===filter在python3中的用法

l =  range(0,20)

def f(x):
    if x%2 == 0:
        return True

print(list(filter(f,l)))

#和python2的区别在于,要加一个list

 

posted @ 2017-08-15 22:09  botoo  阅读(843)  评论(0编辑  收藏  举报