Python特殊语法:filter、map、reduce、lambda
filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)返回:
>>> def f(x): return x % 2 != 0 and x % 3 != 0
>>> filter(f, range(2, 25))
[5,
转载
2015-01-14 14:35:16 ·
524 阅读 ·
0 评论