IndentationError:unindent与任何外部缩进级别都不匹配 [英] IndentationError: unindent does not match any outer indentation level
本文介绍了IndentationError:unindent与任何外部缩进级别都不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我编译下面的Python代码时,我得到
When I compile the Python code below, I get
IndentationError:unindent与任何外部缩进级别都不匹配
IndentationError: unindent does not match any outer indentation level
import sys
def Factorial(n): # Return factorial
result = 1
for i in range (1,n):
result = result * i
print "factorial is ",result
return result
为什么?
推荐答案
其他海报可能是正确的……选项卡中可能混有空格.尝试进行搜索和replace将所有选项卡替换为几个空格.
Other posters are probably correct...there might be spaces mixed in with your tabs. Try doing a search & replace to replace all tabs with a few spaces.
尝试一下:
import sys
def Factorial(n): # return factorial
result = 1
for i in range (1,n):
result = result * i
print "factorial is ",result
return result
print Factorial(10)
这篇关于IndentationError:unindent与任何外部缩进级别都不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文