我的代码如下:功能不改变全局变量
done = False
def function():
for loop:
code
if not comply:
done = True #let's say that the code enters this if-statement
while done == False:
function()
出于某种原因,当我的代码进入if语句,它与函数完成之后,在没有退出while循环()。
,但如果我这样的代码是:
done = False
while done == False:
for loop:
code
if not comply:
done = True #let's say that the code enters this if-statement
...退出while循环。这里发生了什么?
我确定我的代码输入了if语句。我还没有运行调试器,因为我的代码有很多循环(相当大的二维数组),我放弃了调试,因为它非常繁琐。在功能中,“完成”怎么没有被改变?
今天很多Python全局变量的问题。 – icktoofay
谢谢你们!简直不敢相信,但它绝对是与Java/C++不同的触摸 – cYn