zoukankan      html  css  js  c++  java
  • Python中的try-finally

    >>> try:
    ...     raise KeyboardInterrupt
    ... finally:
    ...     print('Goodbye, world!')
    ...
    Goodbye, world!
    KeyboardInterrupt
    Traceback (most recent call last):
      File "<stdin>", line 2, in <module>
    

    A finally clause is always executed before leaving the try statement, whether an exception has occurred or not. When an exception has occurred in the try clause and has not been handled by an except clause (or it has occurred in an except or else clause), it is re-raised after the finally clause has been executed. The finally clause is also executed “on the way out” when any other clause of the try statement is left via a break, continue or return statement.

  • 相关阅读:
    leetcode 34 rust
    leetcode 2 rust
    leetcode 1 rust
    leetcode 20 rust
    leetcode 287 rust
    leetcode 18 rust
    lottery抽奖
    webpack
    webpack(7)-生产环境
    webpack(6)-模块热替代&tree shaking
  • 原文地址:https://www.cnblogs.com/yaos/p/14014397.html
Copyright © 2011-2022 走看看