Python - 从文件中获取Identation错误

时间:2015-10-28 23:00:44

标签: python macos indentation

我正在尝试在python中创建一个小程序,没什么复杂的,但是非常长。刚才,我为'if'语句修改了一个条件,然后通过MacOS终端运行它,因为它有一个Python shell / IDLE(我不知道它是用英语调用的)。

我的文档正好有456行,我得到的'IndentationError'位于'第457行',这是输出:

  

文件“/ Volumes / my usb key / MAIN_0.3.py”,第457行

                    ^
     

IndentationError:预期缩进块

我真的不知道该怎么做,因为我的节目的最后一行都是评论。如果你想要一些代码,我会尝试简单地(和英文)为你们所有,但我想首先知道在“终端”中运行它是不是一个问题,因为它真的很奇怪

编辑:这是一些代码:

#coding= utf-8
#here I put a lot of variables(38), which are all 'int' or 'randint(x, y)'
#then I define some functions, which are all calculus
#here is the main loop :
while (a!=10) and (b > 10):
    function_a(a)
    c=0
    while (c != 1) and (b > 0):
        while b != 0:
            print "\n"
            d=randint(0,20)
            if 0 <= d <= 3: #commentary explaining my program for my buddies at school
                b=function_b(b, e, f, g, h, i, j, a, k, l)
                if b <= 0: #commentary
                    m += n
                    p += a_b
                    if p > 1000: #commentary
                        p -= 1000
                        k += 1
                        print " BRAVO !"
                        print " now", k
                        time.sleep(1)
                        b += b_levelup
                        e += e_levelup
                        f += f_levelup
                        print " you won", b_levelup, "points"
                        time.sleep(1)
                        print " you won", e_levelup, "points"
                        time.sleep(1)
                        print " you won", f_levelup, "points"
                        time.sleep(1)
                print "\n"*2

            if 3 < d <= 8: #commentary

                b=function_b(b, e, f, g, q, r, s, a, k, t)

                if b <= 0: #commentary
                    m += u
                    p += v

                    if p > 1000: #
                        p -= 1000
                        k += 1
                        print " BRAVO !"
                        print " now", k
                        time.sleep(1)
                        b += b_levelup
                        e += e_levelup
                        f += f_levelup
                        print " you won", b_levelup, "points"
                        time.sleep(1)
                        print " you won", e_levelup, "points"
                        time.sleep(1)
                        print " you won", f_levelup, "points"
                        time.sleep(1)
                print "\n"*2

            if 8 < d <= 14: #commentary

                b=function_b(b, e, f, g, w, x, y, a, z, k, a_a)

                if b <= 0: #commentary
                    m += n
                    p += a_b
                    if p > 1000: #commentary
                        p -= 1000
                        k += 1
                        print " BRAVO !"
                        print " now", k
                        time.sleep(1)
                        b += b_levelup
                        e += e_levelup
                        f += f_levelup
                        print " you won", b_levelup, "points"
                        time.sleep(1)
                        print " you won", e_levelup, "points"
                        time.sleep(1)
                        print " you won", f_levelup, "points"
                        time.sleep(1)
                print "\n"*2

            if 15 <= d <= 16:#commentary
                a_c += 1
                function_c()

            if d == 17: #commentary
                a_d += 1
                function_d()

            #boss commentary
            if (d == 18) and (a_d == 0):
                print " mkay"
                time.sleep(2)
                print " nope"
                print " next door"

            #commentary
            if (d == 18) and (a_d >= 1):
                print " arrived"
                time.sleep(2)
                print " wanna go ?"
                print " yes - 1"
                print " No - any other"
                a_e=input(" ")
                if a_e == 1:
                    #boss commentary

1 个答案:

答案 0 :(得分:1)

评论不是陈述,所以当你这样做时

if something:
    # Comment

if没有身体。这是一个语法错误。如果你想要一个do-nothing占位符体,那就是pass语句的用途。

if something:
    # Comment
    pass