Python:如何忽略异常并继续? [英] Python: How to ignore an exception and proceed?

查看:128
本文介绍了Python:如何忽略异常并继续?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个尝试...除了我的代码中的块,当一个异常是抛出。我真的只想继续使用代码,因为在这种情况下,一切仍然能够运行。问题是如果你将except:block留空或#do没有,它会给你一个语法错误。我不能使用继续,因为它不在循环。有没有一个可以使用的关键字,告诉代码呢?

I have a try...except block in my code and When an exception is throw. I really just want to continue with the code because in that case, everything is still able to run just fine. The problem is if you leave the except: block empty or with a #do nothing, it gives you a syntax error. I can't use continue because its not in a loop. Is there a keyword i can use that tells the code to just keep going?

推荐答案

except:
    pass

这篇关于Python:如何忽略异常并继续?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆