import requests url = '和谐://url/upload' file_path = 'xxx.txt' with open(file_path, 'rb') as f: file_content = f.read() headers = { 'Content-Length': str(len(file_content)) } response = requests.put(url, data=file_content, headers=headers) print(response.status_code)