加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-20 11:34:44 所属栏目: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 在“#什
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.如果没有什么特定的,你可以捕捉,除了例外

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读