n == 7给我一个缩进错误

时间:2013-03-19 02:00:05

标签: python

# Rate Our Love !! 

def love(n):
    if n < 0 : 
        print "Why would it be negative?!" 
    elif n == 0 : 
        print "well that is just hurtful" 
    elif n == 1 :
        print "I REALLY love you" 
    elif n == 2 : 
        print "You make me smile at least once, each and every day"
    elif n == 3 : 
        print"you wouldn't believe how annoying it was to get this program to run properly! but it was worth it"
    elif n == 4 : 
        print "let's " + "shoot a little higher than that"
    elif n == 5 : 
        print "you're unforgettable, that's what you are" 
    elif n == 6 :
        print "always have, always '____' *hint* fill in the blank " 
    elif n == 7 :
        print "i could never leave you, I love you too much" 
    elif n == 8 : 
        print "an 8/10 is still only a B, maybe I'm not trying hard enough" 
    elif n == 9 : 
        print " well, I'm not perfect yet, could have seen that one coming. Guess I just have to keep trying :)" 
    elif n == 10 : 
        print " i think you're exaggerating, i really am not that good yet"     
    else:
        print "I still really hope that we could get married someday." 

如果n == 7,如果其格式与此定义的其余部分一样,为什么我会一直收到缩进错误?

1 个答案:

答案 0 :(得分:8)

尝试使用python -t

运行

如果您正在混合空格和制表符,那么它会警告您,看起来您有相同的缩进级别,而实际上您可能没有。

从手册页:

  

<强> -t
  当源文件混合制表符和空格以进行缩进时,发出警告,使其依赖于以空格表示的制表符的价值。发生错误时                 选项有两次。