def func(): return [lambda x: x*i for i in range(5)] def foo(): return [m(2) for m in func()] res = foo() print(res) >>> [8, 8, 8, 8]
闭包函数延迟机制的面试题
原文:https://www.cnblogs.com/KbMan/p/11192084.html