import requests
res = requests.get('https://automatetheboringstuff.com/files/rj.txt')
print(type(res))
print(res.status_code == requests.codes.ok)
print(len(res.text))
print(res.text[:250])
res = requests.get('http://inventwithpython.com/page_that_does_not_exist')
res.raise_for_status()
res = requests.get('http://inventwithpython.com/page_that_does_not_exist')
try:
res.raise_for_status()
except Exception as exc:
print(f'There was a problem {exc}')
In lines 5 and 6
.text
is used. Why does it have to be used? Why the content of Response type res can't be printed? And if an extension must be added why not
.txt
?