Python3调用示例 签名的使用 signature hmacsha256(base64.b64decode(kdate), presignature.encode("utf8")) 将数据整合得到真正的header中的内容 signheader "{0} Headersappkey;ctyuneoprequestid;eopdate Signature{1}".format(ak, signature.decode()) 返回requestid eopdate和signheader return requestid, eopdate, signheader 向服务发送请求 def dopost (url, headers, params): response requests.post(url, datajson.dumps(params), headersheaders) try: print (response.statuscode) print (response.json()) except AttributeError: print ("请求失败") if name 'main': 请求地址 requesturl " 官网accessKey ctyunak accessKey 官网securityKey ctyunsk 'securityKey' 控制台我的应用中获取的appKey aiappkey 'appKey' body内容从本地文件中获取 打开图片文件 f open (r'test.jpeg', 'rb') imgbase64 base64.b64encode(f.read()).decode() body内容 params {"imageContent": imgbase64} 调用getsignature方法获取签名 requestid, eopdate, signheader getsignature(ctyunak, ctyunsk, aiappkey, params) 生成请求header 请求header headers { 'ContentType': 'application/json;charsetUTF8', 'ctyuneoprequestid': requestid, 'appkey': aiappkey, 'EopAuthorization': signheader, 'eopdate': eopdate, 'host': 'aiglobal.ctapi.ctyun.cn' } print ("请求头部:") print (headers) 执行post请求 dopost(requesturl, headers, params)