1

When I do this:

url = 'http://www.example.com' values = {'name' : 'Michael Foord', 'location' : 'Northampton', 'language' : 'Python' } data = urllib.parse.urlencode(values) data = data.encode('utf-8') # data should be bytes req = urllib.request.Request(url, data) print(req) 

Using Python, I get this:

< urllib.request.Request object at 0x0000000002E8FF60 > 

What does it mean?

What happened to my req variable?

Could someone explain this to me?

1 Answer 1

3

What you are seeing is an object of type Request A request object is an abstraction of a URL request.

To view the elements, you can do req.__dict__

Also, dir(req) would give you the available keys in the request object.

Here is the documentation of the Request class

The reason you are seeing <urllib.request.Request object at 0x0000000002E8FF60> is, by default it provides the object in the following format:

(Normally, you would override this by specifying __unicode__, which would refer to some property within the class object)

Sign up to request clarification or add additional context in comments.

Comments