the return of urllib.request.urlopen("http://www.example.com/", params)

tunpishuang tunpishuang at gmail.com
Wed Apr 1 00:17:29 EDT 2009


hey guys , i'm new in python ...here i got a little problem that get
me confused...
i wanna do an uthentication of an login page , here is the example
from the python lib ref. :

>>> import urllib.request
>>> import urllib.parse
>>> params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.request.urlopen("http://www.musi-cal.com/cgi-bin/query?%s" % params)
>>> print(f.read())

i wanted to know what the the return value of f ,,if it's an instance
of http.client.HTTPResponse
and why the return source of the web page is quote like this :

b'<html></html>'

if i wanna to read the first 10 bytes of f and compare with the web
source.
what the first 10 bytes will be ? is it "b'<html><h"  or "<html></ht"
or something else.
i've debug for this script , but still got the error that they don't
match~

any suggestions?

pardon me for the poor english~



More information about the Python-list mailing list