python如何故意留下缩进行空白?

for line in sys.stdin:
    line = line.strip()
    uid, profile = line.split('\t')
    try:
        process(profile)
    except:
        # do nothing and skip this profile

我想跳过所有抛出异常的配置文件.但是python给了我

IndentationError: expected an indented block

在“#什么都不做,跳过这个配置文件”这一行.

我怎么告诉python什么都不做?

最佳答案 Python“NOP”是
pass

...
except:
    pass

也就是说,从不使用裸露的条款.他们捕获的东西就像你几乎绝对不想自己处理的KeyboardInterrupt.如果没有什么特定的,你可以捕捉,除了例外

点赞