这段代码有几个闭包
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 fs
f1, f2, f3 = count()
print f1(), f2(), f3()
我知道g 是闭包,那么f是闭包吗?
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 fs
f1, f2, f3 = count()
print f1(), f2(), f3()
我知道g 是闭包,那么f是闭包吗?
2018-09-18
举报