‘docs.python.org’ about ‘exception’
def exception_example():
a = 0
try:
a = 1/0
except Exception as e:
print(e)
else:
a = 1
finally:
print(a)
class MyException(Exception):
pass
def my_exception_example():
my_exception = MyException("my exception!")
try:
raise my_exception
except Exception as e:
print(e)
else:
print("no exception.")
finally:
print("exception process end")
if __name__ == '__main__':
exception_example()
my_exception_example()