如何在Python的try块中继续下一行? [英] How to continue with next line in a Python's try block?
本文介绍了如何在Python的try块中继续下一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
eg
try:
foo()
bar()
except:
pass
当foo函数引发异常时,如何跳至下一行( )并执行它?
When foo function raise an exception, how to skip to the next line (bar) and execute it?
推荐答案
从 bar()
中取出 try
块:
try:
foo()
except:
pass
bar()
Btw。,注意排除所有
子句。最好选择性地捕获您知道可以处理/忽略的异常。
Btw., watch out with catch-all except
clauses. Prefer to selectively catch the exceptions that you know you can handle/ignore.
这篇关于如何在Python的try块中继续下一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文