[Tutor] format string

devayani barve devayani.barve at gmail.com
Wed Jul 19 14:58:21 CEST 2006


Hi

This is my program:

import urllib
ans='y'
while ans=='y':
    name=raw_input("Enter search:")
    name=name.replace(' ','+')
    name=name.replace('&','%26')
    go_url="http://www.google.co.in/search?hl=en&q=%s"
%name+"&meta=lr\%3Dlang_en"
    print go_url
    page = urllib.urlopen(go_url).read()
    ans=raw_input("do you want to continue?: ")

It gives following error:
Traceback (most recent call last):
  File "C:\python\urllib.py", line 1, in -toplevel-
    import urllib
  File "C:\python\urllib.py", line 9, in -toplevel-
    page = urllib.urlopen(go_url).read()
AttributeError: 'module' object has no attribute 'urlopen'

What does it mean? also I tried to assign go_url as

    go_url="http://www.google.co.in/search?hl=en&q=%s&meta=lr\%3Dlang_en"
%name

It takes the % in "%3D" as a part of  format is there a way I can overcome
this retaining the same manner of assinging?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060719/3e684981/attachment.htm 


More information about the Tutor mailing list