a newbie question

larryzhang zhangle2002 at gmail.com
Mon Apr 13 01:49:34 EDT 2009


On Apr 12, 11:01 pm, Peter Otten <__pete... at web.de> wrote:
> zhangle2... at 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

It works. Thanks a lot Peter.

Larry



More information about the Python-list mailing list