0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

例外処理

Last updated at Posted at 2020-02-16
ex.py
l = [2,4,5,8]

try:
    l[5]
except NameError as ex:
    print('エラーメッセージ:', ex)
except Exception as ex: #その他の例外をキャッチ(ただし、この使い方は推奨されない)
    print('エラーメッセージ:',ex)
else:
    print('成功した時のみ実行されます')
finally:
    print('例外をキャッチできなかった場合(プログラムが正常終了しなかった場合)も含めて、必ず実行されます')
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?