根源在于 Python’s closures are late binding. This means that the values of variables used in closures are looked up at the time the inner function is called.
你把方括号[]改成(),从list改成generator 输出就变“正常”了。
【 在 feng321 的大作中提到: 】
: def create_multipliers():
: return [lambda x : i * x for i in range(5)]
: print(create_multipliers())
: ...................
--
FROM 120.229.48.*