def count(): fs = [] for i in range(1, 4): def f(x): def g(): return x*x return g y=f(i) fs.append(y) return fs f1, f2, f3 = count() print f1(), f2(), f3()
这是Python闭包求range(1,4)里面每个元素的乘积,如果求任意list的乘积怎么做??
相关分类