码迷,mamicode.com
首页 > 其他好文 > 详细

map,filter

时间:2019-07-18 19:35:57      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:span   yield   code   turn   map   blog   ret   target   col   

def is_odd(n):
    return n % 2 == 1

newlist = filter(is_odd, [i for i in range(0,5)])
print(list(newlist))

def sun(x,y):
    return x+y
print(list(map(sun,[2,3,1,2],[6,6,1,2])))

 yield的用法:

很好的一个博客

 

map,filter

标签:span   yield   code   turn   map   blog   ret   target   col   

原文地址:https://www.cnblogs.com/two-peanuts/p/11209431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!