import requests # 下面是上传图片的函数 #定义请求头 headers={ "X-Access-Token":token, "X-Tenant-Id":tenantId } def upload_image(image_path, url): with open(image_path, 'rb') as f: files = {'file': (image_path, f, 'image/jpeg')} # 假设图片为 JPEG 格式,可根据实际修改 # 'file': ('image.jpg', f, 'image/jpeg') response = requests.post(url, files=files, headers=headers) if response.status_code == 200: print("图片上传成功") print(response.json()) print(response.status_code) else: print(f"图片上传失败,状态码: {response.text}") # 调用函数,替换为实际的图片路径和上传的 URL upload_image('图片地址', "URL")
08-24
741
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-16