Home >Backend Development >Python Tutorial >The difference and connection between python3 and python2 exception handling
In python2.x, exceptions are handled like this. Add a comma "," after the exception base class and then follow the exception type
import traceback
try: 1/0 except Exception , err: print err
In python3.x, exceptions are handled like this. The base class connects the exception type through the keyword "as"
import traceback
try: 1/0 except Exception as err: print(err)
The above is the entire content of this article, I hope you all like it.