filter(function, iterable): Construct a list from those elements of iterable for which function returns true. 对iterable中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于iterable的类型)返回. iterable包括列表,iterator等.一个简单例子,过滤出一个整数列表中所有的奇数 >>&…
# lambda,filter,map,reduce from functools import reduce print('返回一个迭代器') print((x) for x in range(5)) print('迭代器转换为tuple') print(tuple((x) for x in range(5))) print('.......') print('匿名函数lambda传参方式一') print((lambda x, y: x+y)(1, 2)) print((lambda x:…