+ 1
How do you handle all possible exceptions in python
2 odpowiedzi
+ 5
Bro u can use the except statement without the exception specified to handle all possible exception
An except statement without any exception specified will catch all errors. These should be used sparingly, as they can catch unexpected errors and hide programming mistakes.
Syntax:
try:
print(1/0)
except:
print("Except")
Hence this will catch all possible errors
Thanks
+ 2
From the documentation:
8.3. Handling Exceptions
https://docs.python.org/3/tutorial/errors.html
It might be more beneficial to ask a more specific question in the future. You may find it helpful to review the following:
https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community
Be sure not to miss the link to the Community Guidelines toward the bottom of the article.
Happy coding!