filter() 过滤函数

dic = {'k1': 10, 'k2': 100, 'k3': 50, 'k4': 90}
print(list(filter(lambda x: x[1] > 50, dic.items())))  # 把值大于50的由元祖组成的键值对过滤出来。

 

 

movie_people=['alex_sb','wupeiqi_sb','linhaifeng','yuanhao_sb']
print(filter(lambda n:not n.endswith('sb'),movie_people))



res=filter(lambda n:not n.endswith('sb'),movie_people)
print(list(res))


print(list(filter(lambda n:not n.endswith('sb'),movie_people)))
posted @ 2020-01-13 10:59  小马嘿  阅读(847)  评论(0)    收藏  举报