Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
604 views
in Technique[技术] by (71.8m points)

python - IndentationError:unindent与任何外部缩进级别都不匹配(IndentationError: unindent does not match any outer indentation level)

When I compile the Python code below, I get

(当我编译下面的Python代码时,我得到)

IndentationError: unindent does not match any outer indentation level

(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

Why?

(为什么?)

  ask by cbrulak translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

(尝试进行搜索和替换,以所有空格替换几个空格。)

Try this:

(尝试这个:)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...