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