相关疑难解决方法(0)

不明白为什么会发生UnboundLocalError

我在这做错了什么?

counter = 0

def increment():
  counter += 1

increment()
Run Code Online (Sandbox Code Playgroud)

上面的代码抛出了一个UnboundLocalError.

python scope global-variables

153
推荐指数
5
解决办法
18万
查看次数

标签 统计

global-variables ×1

python ×1

scope ×1