Try-except clause with an empty except code [duplicate]

Solution 1:

try:
    do_something()
except:
    pass

You will use the pass statement.

The pass statement does nothing. It can be used when a statement is required syntactically but the program requires no action.

Solution 2:

Use pass:

try:
    foo()
except: 
    pass

A pass is just a placeholder for nothing, it just passes along to prevent SyntaxErrors.

Solution 3:

try:
  doSomething()
except: 
  pass

or you can use

try:
  doSomething()
except Exception: 
  pass