不明白
Topic source其实这个函数是返回了个带有参数n的另一个函数,我写一个例子你自己运行一下就明白了:
def a(x):
return lambda y: x + y
#调用a(x)
b = a(2) #返回了另外一个函数b(x),内容为:x+2
#调用b(x)
b(3)
5 # 得到结果5
#直接输入2个参数
a(2)(3)
5 # 得到结果5
def primes(): yield 2 it = _odd_iter() # 初始序列 while True: n = next(it) # 返回序列的第一个数 yield n it = filter(_not_divisible(n), it) # 构造新序列 构造新序列那句: filter里面_not_divisible函数为什么要带(n),为什么不能省去?
- 1
吴利民5705255624
def _not_divisible(n): return lambda x: x % n > 0 return返回了什么东西?