zhangle2...@gmail.com wrote: > I am just learning Python and get a problem when trying this example: > > from urllib import urlopen > doc=urlopen("http://www.python.org").read() > print(doc) > > when i run this, i was tould that 'cannot import name "urlopen" > > > What's wrong with this code? Do i need to place my code in some > specific directory? Thanks a lot. '
This function has been moved in Python 3.0. Change your import to from urllib.request import urlopen If you are learning with a book using Python 2.x consider switching to Python 2.5 or 2.6 to try out the examples. Peter -- http://mail.python.org/mailman/listinfo/python-list