demo_requests_post_headers.py:
import requests url = 'https://w3schools.com/python/demopage.asp' myobj = {'somekey': 'somevalue'} #use the 'headers' parameter to set the HTTP headers: x = requests.post(url, data = myobj, headers = {"HTTP_HOST": "MyVeryOwnHost"}) print(x.text) #the 'demopage.asp' prints all HTTP Headers
C:\Users\My Name>python demo_requests_post_headers.py
HTTP_CONNECTION:keep-alive
HTTP_ACCEPT:*/*
HTTP_ACCEPT_ENCODING:gzip, deflate
HTTP_HOST:MyVeryOwnHost
HTTP_USER_AGENT:python-requests/2.22.0