>我试图从视频中获取情感
下面是我的代码,
当我运行此代码时,总是收到此错误
b'{"error":{"code":"BadArgument","message":"Failed to 反序列化 JSON 请求。
import http.client, urllib.request, urllib.parse, urllib.error, base64, sys
headers = {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': 'xxxxxxxxxxx',
}
params = urllib.parse.urlencode({
})
body = "{ 'url': 'http://www.dropbox.com/s/zfmaswf8s9c58om/blog2.mp4' }"
try:
conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
conn.request("POST", "/emotion/v1.0/recognizeinvideo?%s" % params, "
{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print(e.args)
您忘记用真实的东西替换占位符{body}
。
conn.request("POST", "/emotion/v1.0/recognizeinvideo?%s" % params, body, headers)