python requests set user agent

import requests

url = 'SOME URL'

headers = {
    'User-Agent': 'My User Agent 1.0',
    'From': 'youremail@domain.com'  # This is another valid field
}

response = requests.get(url, headers=headers)

Here is what the above code is Doing:
1. We’re creating a dictionary called headers. This dictionary contains the headers we want to send with our request.
2. We’re making a GET request to the specified URL, passing in the headers dictionary as an argument.
3. We’re storing the response object in the response variable.