需使用MultipartEncoder包
import requests
from requests_toolbelt import MultipartEncoder
headers = {'Cookie': f'1QAZ2WSX3EDC={cookie}; __RequestVerificationToken={token}',
'Upgrade-Insecure-Requests': '1'}
excel_file = open(file, 'rb')
multipart_encoder = MultipartEncoder(
fields={'ConfirmationCategory': (None, '3'),
'file': (file_name, excel_file, "application/vnd.ms-excel.sheet.macroEnabled.12"),
'path': (None, f'C:\\fakepath\\f{file_name}'),
'EngagementCode': (None, engagement_code),
'isUseTool': (None, '0'),
'Category': (None, '3'),
'TemplateID': (None, '1'), },
boundary='------WebKitFormBoundaryGBsSQdG8BdI5tzVZ')
headers['Content-Type'] = multipart_encoder.content_type
session = requests.Session()
response = session.post(url=url, auth=AUTH, headers=headers)