def count(): fs = [] for i in range(1, 4): def f(j): def g(): return j*j return g r = f(i) fs.append(r) return fsf1, f2, f3 = count()print f1(), f2(), f3()在 r = f(i)处不理解 f(i) == g 而不是 g(),这个r是否等于 j*j 是不是r() 才等于j*j,fs.append(r)添加的是什么啊测试如下def f(i): def g(): return i*i return g>>> f(1)<function f.<locals>.g at 0x01106A08>>>> f(1)()1>>> f(9)()81>>> q = f(8)>>> q<function f.<locals>.g at 0x01106A08>
添加回答
举报
0/150
提交
取消