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的用法:
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的用法: