The following code works as expected with python version 2.6.5, but with
version 3.1.2 I get the following error:
pierre:/MyCode/mesProjets$ py3 test.py
Traceback (most recent call last):
File "test.py", line 3, in <module>
sock = urllib.urlopen("http://diveintopython.org/")
AttributeError: 'module' object has no attribute 'urlopen'
The code:
#example 8.5 of diveintopython.org/
import urllib
sock = urllib.urlopen("http://diveintopython.org/")
htmlSource = sock.read()
sock.close()
print (htmlSource)
What is the proper syntax in version 3?
Thank you,
Your help is much appreciated.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor