课程
/后端开发
/Python
/python进阶
最后一句话难道是调用闭包的语句?
2018-08-26
源自:python进阶 2-9
正在回答
def count(): fs = [] for i in range(1, 4): def f(k=i): return k*k fs.append(f) return fsf1, f2, f3 = count()print f1(), f2(), f3()
def count():
fs = []
for i in range(1, 4):
def f(i):
return i*i
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): def g(): return j*j return g r = f(i) fs.append(r) return fs f1, f2, f3 = count() print f1(), f2(), f3()
能贴出图或者代码么?
举报
学习函数式、模块和面向对象编程,掌握Python高级程序设计