The reason this is a problem is because python2 and python3 have different syntax
Python2 and 3 deal with the except clause in a slightly different syntax, which is worth noting;
Python2
try:
print ("hello world")
except ZeroDivisionError, err: # , Add reason parameter name
print ('Exception: ', err)
Python3
try:
print ("hello,world")
except ZeroDivisionError as err: # as Add reason parameter name
print ('Exception: ', err)
As seems to work if you want compatibility
Read More:
- [Solved] Failed to install PIP for MacOS, prompt: syntax error: invalid syntax
- [Solved] PIP Install tensorflow error: syntax error: invalid syntax
- [Solved] Python operate Kafka error: SyntaxError: invalid syntax
- [Solved] rdd.foreach(print) Error: SyntaxError: invalid syntax
- [Solved] sys.stderr.write(f“ERROR: {exc}“) ^ SyntaxError: invalid syntax
- [Solved] Python sqlite3.OperationalError: near “?“: syntax error
- Python Use sqlalchemy Error: pymssql.ProgrammingError: (102, b“Incorrect syntax near ‘(‘.DB-Lib error
- Python Error: bash syntax error near unexpected token `newline’
- Python_Syntax error: unexpected character after line continuation character
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- python3 Execute except Exception, e Error [How to Solve]
- [Solved] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- Robotframework post error“:“Internal Server Error“,“message“:“syntax error, expect
- Python3.7 Capture exception error: Too broad exception clause
- Invalid python sd, Fatal Python error: init_fs_encoding: failed to get the Python cod [How to Solve]
- Python PIP Fatal error in launcher: Unable to create process using ‘“e:\program files\programdata
- Python: How to Use try exception to Display Abnormal Error Information
- Python Pandas Typeerror: invalid type comparison
- Python: Django exception when executing migrate operation: django.db.utils.OperationalError: (1051, “Unknown table’xxx’”)
- python2.7 ExcelWriter error Exception caught in workbook destructor. Explicit close() may be require