# Python CodeRecipe|tryの使い方
❮ Home ❮ Python Keywords
# tryの例1
Try a block of code, and decide what to to if it raises an error:
try: x > 3except: print("Something went wrong")
# tryの定義及び使い方
try関数はtry ...。除く ブロック。エラーが含まれている場合は、コード・テストのブロックを定義します。 エラー・タイプごとに異なるブロックを定義し、 何も問題がなければ、以下の例を参照してください。
# tryの例2
Raise an error and stop the program when there is an error in the try
block:
try: x > 3except: Exception("Something went wrong")
Related Pages The except keyword. The finally keyword.
❮ Home ❮ Python Keywords