I am using the requests module of python. In one of the post calls I am getting response cookies. I wanted to read them so I did:
if a in response.cookies:
print "Found"
then I did : print type(response.cookies)
. This gave me <class 'requests.cookies.RequestsCookieJar'>
then I did: print response.cookies
. This gave me <RequestsCookieJar[<Cookie a=asdasdd for vn>]>
The type says it is of type Class. The printing of the variable gives a list and I am able to access it like a dictionary. Please explain the print response.cookies
syntax.
I'm not sure why you think there's a contradiction here. The RequestsCookieJar class implements the dictionary interface by subclassing collections.MutableMapping
, so you can access items by key.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.