You can use the requests's api from python like this way:
import requests
import base64
pat = 'token'
authorization = str(base64.b64encode(bytes(':'+pat, 'ascii')), 'ascii') #you can use this function to encode the token to base64 or directly encode the code to base64 and after that, use token with authorization variable
headers = {
'Authorization': 'Basic '+authorization,
'Content-Type': 'application/json-patch+json'
}
data = [
{
"op": "add",
"path": "/fields/System.Title",
"from": 'null',
"value": "Test"
}
]
response = requests.post(
url="https://dev.azure.com/{project}/{team}/_apis/wit/workitems/$task?api-version=6.0-preview.3", json =data, headers=headers)
print(response.json())
#this example you can create a workitem in task, for example