Use of try, except, else and finally in python
To handle exceptions that occurred in python code, you can use try-except in python. The else statement can also be used to verify that the code was executed successfully.
except Exception as e:
print("Repr Error : " + repr(e))
print("Error : " + str(e))
print("Program Executed successfully")
print("Finally always executes")
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.
Repr Error : NameError("name 'some_undefined_method' is not defined",)
Error : name 'some_undefined_method' is not defined
Finally always executed