कोड के निम्नलिखित स्निपेट दोनों एक ही काम करते हैं। वे हर अपवाद को पकड़ते हैं और except:ब्लॉक में कोड निष्पादित करते हैं
स्निपेट 1 -
try:
#some code that may throw an exception
except:
#exception handling code
स्निपेट 2 -
try:
#some code that may throw an exception
except Exception as e:
#exception handling code
दोनों निर्माणों में वास्तव में क्या अंतर है?
except Exception, e:है औरexcept Exception as e:। यह सवाल पूछता है कि क्या अंतर हैexcept:औरexcept Exception as e:।