0
我想明白了,局部和全局变量在python是如何工作的,这里是我的代码为什么我得到这段python代码的intendation错误?
def f(s):
print s
global s
print s
s = "I hate spam."
f('aa')
上运行的脚本,这里是我得到
File "global_local.py", line 4
global s
^
IndentationError: unindent does not match any outer indentation level
谁能解释错误对我来说这是为什么?
您可能在您的编辑器中混合了制表符和空格。 –
无论如何,您无法完成这项工作:'SyntaxError:name's'是本地和全局'。 –
@ Two-BitAlchemist我写了coed来触发这个错误本身,但是却得到了这个错误。这就是为什么我在这里发布它 – Dude