为什么这是Python中的意外缩进?

Léo*_* 준영 1 python python-2.7

#!/usr/bin/python

try:
    f = open("/home/masi/r.raw", "r+")
    aBuf = f.seek(4) 
except:
    print "Error at position : ", position

events = []
for i in range(100):
    aBuf = f.seek(4);

    try:
        if aBuf[:4] == b'\xFA\xFA\xFA\xFA':
            print("E")

    except:
    #   print "\0"

f.close()
Run Code Online (Sandbox Code Playgroud)

当我评论除了打印,我得到错误

    f.close()
    ^
IndentationError: expected an indented block
Run Code Online (Sandbox Code Playgroud)

我想我需要尝试 - 除非因为if子句经常是假的.

为什么我会得到这种意外的压痕?

Mel*_*Mel 10

except 期待一个或多个陈述.

你可以写:

try:
    if aBuf[:4] == b'\xFA\xFA\xFA\xFA':
        print("E")
except:
    pass
Run Code Online (Sandbox Code Playgroud)

警告
如评论中所述,使用它不是一个好习惯except: pass.
看看为什么"除了:传递"一个糟糕的编程习惯?.