import traceback, sys
number1 = 100
number2 = 0
print('start')
try:
answer = number1 / number2
print(answer)
except ZeroDivisionError as e:
print('It does not break at 0.')
sys.stderr.write(traceback.format_exc())
finally:
print('end')
Execution result
start
It does not break at 0.
end
Run-time error
Traceback (most recent call last):
File "Main.py", line 9, in <module>
answer = number1 / number2
ZeroDivisionError: division by zero
By doing this Even if you only look at the output tab It is easy to understand what kind of error is occurring.
Also, If you look at the runtime error tab, You can check the details of the error.
Recommended Posts