except Exception, ex: ^ SyntaxError: invalid syntax

The python program reports an error:

except Exception, ex:
^
SyntaxError: invalid syntax

As shown in the figure below:
Insert picture description here
Reason:
Because the python version I use is 3.7, except Exception, ex: This syntax needs to be run with python2 version

Solution:

except Exception, ex:

To

except Exception as ex:

After the compilation is normal, as shown in the following figure:
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_47542175/article/details/114401396