0
0

More than 3 years have passed since last update.

python3 例外処理 (記録)

Posted at
class MyExcepiton(Exception):
  pass

def div(a,b):
  try:
    if (b < 0):
      raise MyExcepiton("not minus")
    print(a/b)
  except ZeroDivisionError:
    print("not by zero!")
  except MyExcepiton as e:
    print(e)
  else:
    print("no exception!")
  finally:
    print("計算が終了しました")
div(10,-2)

0
0
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
0