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)
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme