Problem Statement
What is the main benefit of using requests.Session?
Explanation
A Session reuses TCP connections and carries shared headers, auth, and cookies across calls. This reduces latency and keeps stateful interactions simple.
For retries, attach a Retry adapter from urllib3; it is not automatic.
Code Solution
SolutionRead Only
s=requests.Session(); s.headers.update({'Authorization':'Bearer X'})
s.get(url)Practice Sets
This question appears in the following practice sets:
