前回はファイル操作を学び、「プログラムが外部ファイルの情報を扱える」ところまで踏み込みました。 しかし、プログラムを書いていると、必ずといっていいほど避けられないのが「エラー(バグ)」です。例えば… ファイルが存在しないのに読もうと ...
前編では基本的な例外処理の手法、および例外の種類について扱いました。中編では、 例外処理の場合分け どのような例外が発生しているかの確認 例外をわざと発生させるテクニック について解説していきます。 例外処理の場合分け 前回は、try/exceptに ...
プログラムを書いていると、一つの処理の中で「いろいろな種類のエラー」が起きる可能性があります。 例えば、設定ファイルを読み込んで計算する処理を想像してみてください。 「そもそもファイルがない」かもしれない。 「必要なデータ(キー)が ...
One of the features that makes Python a great programming language is exceptions for error handling. Exceptions are convenient in many ways for handling errors and ...
except Exception as e: # Here we catch the error and it print the error line and programm excutes the forward operation.
Below is some common exceptions errors in Python: ###IOError If the file cannot be opened. ###ImportError If python cannot find the module ###ValueError Raised when a ...