AttributeError when using request.post () in a `with` statement
A / C requests python documentation , where the operator can be used with higher speed requests.
with requests .get (' http://httpbin.org/get ', stream = True) as r: # Do something with the response here.
So why does this return "Attribute Error"?
Traceback (most recent call last):
File "<pyshell#101>", line 1, in <module>
with requests.post(url,headers=headers,data=data,stream=True) as post_res:
AttributeError: __exit__
code:
with requests.post(url,headers=headers,data=data,stream=True) as post_res:
print(b'Name' in post_res.content)
PS This works fine without the "c" instruction.
+3
source to share