# Python CodeRecipe|finallyの使い方

Home Python Keywords

# finallyの例1

The finally block will always be executed, no matter if the try block 
  raises an error or not:

    try:  x > 3except:  print("Something went wrong")
    else:  print("Nothing went wrong")finally:  print("The 
    try...except block is finished")

# finallyの定義及び使い方

finally関数はtry ...で使用されます。除く ブロック。これは、try ...。ただし...。elseブロックは final。 finallyブロックは必ず実行されます。 tryブロックでエラーが発生したかどうか。 これは、オブジェクトを閉じてリソースをクリーンアップする場合に便利です。

Related Pages try Keywords. exception Keywords.

Home Python Keywords