Python Try/except With Multiple Except Blocks
try: raise KeyError() except KeyError: print 'Caught KeyError' raise Exception() except Exception: print 'Caught Exception' As expected, raising Exception() on the
Solution 1:
You could add another level of try
nesting:
try:
try:
raise KeyError()
except KeyError:
print "Caught KeyError"
raise Exception()
except Exception:
print "Caught Exception"
Post a Comment for "Python Try/except With Multiple Except Blocks"