Using urlopen in Python2 and Python3
Cecil Westerhof
Cecil at decebal.nl
Mon Aug 24 13:13:51 EDT 2015
In Python2 urlopen is part of urllib, but in Python3 it is part of
urllib.request. I solved this by the following code:
========================================================================
from platform import python_version
if python_version()[0] < '3':
from urllib import urlopen
else:
from urllib.request import urlopen
========================================================================
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
More information about the Python-list
mailing list