Why can't Python increment variable in closure?

摘要

In this code snippet I can print the value of counter from inside the bar function def foo(): counter = 1 def bar(): print("bar", counter) return bar bar = foo() bar() But w...

欢迎在评论区写下你对这篇文章的看法。

评论

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.124.0. UTC+08:00, 2024-04-26 11:03
浙ICP备14020137号-1 $访客地图$