I am getting a syntax error from python for the 'as' statement. I don't know for sure but I suspect my web server has out of date python.
x@y.com [~/www/dmi-tcat/helpers]# python urlexpand.py
File "urlexpand.py", line 70
except HTTPError as e:
^
SyntaxError: invalid syntax
x@y.com [~/www/dmi-tcat/helpers]#
Can anyone confirm this and is there a way to write the same piece of code without the as statement? My host doesn't want to upgrade python at the minute.
The older python syntax is
try:
...
except HTTPError, e:
...
If you want to catch multiple error types, pass a tuple:
try:
...
except (AttributeError, TypeError), e:
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.