各位大神,为什么f(j)里还要定义一个匿名函数,不能直接return j*j呢?谢谢
def count(): fs = [] for i in range(1, 4): def f(j): return lambda :j*j fs.append(f(i)) return fs f1, f2, f3 = count() print (f1(), f2(), f3())
def count(): fs = [] for i in range(1, 4): def f(j): return lambda :j*j fs.append(f(i)) return fs f1, f2, f3 = count() print (f1(), f2(), f3())
2018-07-31
举报