当我编译下面的Python代码时,我得到了
IndentationError:unindent与任何外部缩进级别都不匹配
import sys
def Factorial(n): # Return factorial
result = 1
for i in range (1,n):
result = result * i
print "factorial is ",result
return result
Run Code Online (Sandbox Code Playgroud)
为什么?
我有一个Python脚本:
if True:
if False:
print('foo')
print('bar')
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行我的脚本时,Python提出了一个IndentationError:
File "script.py", line 4
print('bar')
^
IndentationError: unindent does not match any outer indentation level
Run Code Online (Sandbox Code Playgroud)
我一直在玩我的程序,我还能够产生其他三个错误:
IndentationError: unexpected indentIndentationError: expected an indented blockTabError: inconsistent use of tabs and spaces in indentation这些错误意味着什么?我究竟做错了什么?我该如何修复我的代码?