Python 3.x microsoft情感api视频Python 3中的错误消息

Python 3.x microsoft情感api视频Python 3中的错误消息,python-3.x,microsoft-cognitive,Python 3.x,Microsoft Cognitive,我试着从一段视频中了解情绪 下面是我的代码 当我运行此代码时,总是会出现此错误 b'{“error”:{“code”:“BadArgument”,“message”:“未能反序列化JSON请求。”}}知道原因吗? import http.client, urllib.request, urllib.parse, urllib.error, base64, sys headers = { 'Content-Type': 'application/json', 'Ocp-Apim-Subscri

我试着从一段视频中了解情绪

下面是我的代码

当我运行此代码时,总是会出现此错误

b'{“error”:{“code”:“BadArgument”,“message”:“未能反序列化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)

请格式化python代码,使其易于阅读!