user agent for python

headers = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"}

#Lets test what headers are sent by sending a request to HTTPBin
r = requests.get('http://httpbin.org/headers',headers=headers)
pprint(r.json())

Here is what the above code is Doing:
1. We are creating a dictionary with the key “User-Agent” and the value “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36”
2. We are sending a request to the URL “http://httpbin.org/headers” with the headers dictionary as an argument.
3. We are printing the JSON response from the server.

As you can see, the headers dictionary is sent to the server and the server responds with the headers that were sent.