python try except catches instances of all exceptions

  • 2020-12-22 17:43:52
  • OfStack

As shown below:


try:

 a=1
except Exception as e:
 print (e)

import traceback
import sys
try:
 a = 1
except:
 traceback.print_exc()
 #sys.exc_info() 

Related articles: