E
E
Ernest Vardanyan2020-06-14 12:12:10
Python
Ernest Vardanyan, 2020-06-14 12:12:10

Is it possible to catch 2 exceptions at once?

Hello, I get a TimeoutException error and NoSuchElementException came out, I caught the second one, but I would like to know about the first exception, if you can explain in a stupid language for those who are in the tank (me), I will be grateful. Also would like to know it is possible to catch 2 exceptions at the same time?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2020-06-14
@MrCute

maybe so

try:
    # do something that may fail
except IDontLikeYouException, YouAreBeingMeanException:
    # say please

and it is possible
try:
    # do something that may fail
except IDontLikeYouException:
    # say please
except YouAreBeingMeanException:
    # say please

D
Dr. Bacon, 2020-06-14
@bacon

You can read the documentation https://docs.python.org/3/tutorial/errors.html#han...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question