I'm new to programming with Python. I'd like to set a variable for the Python requests
method (.get
, .post
, etc.).
Something like:
import requests
method = 'get'
url = 'https://google.com'
response = requests.method(url)
This of course results in an error because requests
does not have a .method
option.
It feels like the answer lies with getattr
, but I don't understand what parameters to pass getattr
.
Any advice?
Thank you