import base64 import json import requests # 定义文件路径和请求 URL file_path = 'cat.jpg' url = 'http://192.168.8.20:9000/api/v1.0/predictions' # 读取并进行 Base64 编码 with open(file_path, 'rb') as file: encoded_data = base64.b64encode(file.read()).decode('utf-8') # 创建 JSON 数据 json_data = { "strData": encoded_data } # 发送 POST 请求 response = requests.post(url, json=json_data) # 输出响应 print(response.status_code) print(response.json())