python 3.6 - Except statement gives syntax error -
the code same in book web scraping python according code tested on python version 3.4+. python ide using python 3.6.x, still shows syntax error.
the error is
except(urlerror, httperror, contenttooshorterror) e: ^ syntaxerror: invalid syntax
here's code:
import urllib.request urllib.error import urlerror, httperror, contenttooshorterror def download(url): print('downloading:', url) try: html = urllib.request.urlopen(url).read() except(urlerror, httperror, contenttooshorterror) e: print('download error:', e.reason) html = none return html download('https://en.wikipedia.org/wiki/main_page')
Comments
Post a Comment