You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The examples, at least simpletest, use code structured like this:
print("Fetching text from %s"%TEXT_URL)
response=requests.get(TEXT_URL)
print("-"*40)
print("Text Response: ", response.text)
print("-"*40)
response.close()
In modern Python, using a with statement is idomatic and provides the best resource management, because the need to manually call close (including in exception cases) is removed:
print("Fetching text from %s"%TEXT_URL)
withrequests.get(TEXT_URL) asresponse:
print("-"*40)
print("Text Response: ", response.text)
print("-"*40)