Is it possible to ignore exceptions in exception handling?

Asked 2 years ago, Updated 2 years ago, 88 views

I just want to ignore some code and keep running if there's an exception In this case, how should I try-except? See if I'm right

try :
    shutil.rmtree ( path )
except :
    pass

python exception exception-handling try-except

2022-09-22 13:54

1 Answers

There are two ways. The difference between the two methods is written below.

try:
  doSomething()
except: 
  pass

Ina

try:
  doSomething()
except Exception: 
  pass

Please write it with me. The difference between the two methods is


2022-09-22 13:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.