python 中的请求返回文本而不是 json 中的 HTTP 请求

HTTP request with requests in python returning text instead of json

def thready(name,count):
    payload={'Accept': 'application/json;charset=utf-8', 'X-Mashape-Key': 'key'

            }


    link = "https://montanaflynn-gender-guesser.p.mashape.com/?name=" + name
    r=requests.get(link ,headers=payload)
    print r.headers
    data=r.json()

    print data


count=0

thready("bob",count)

所以我只是尝试在 python 中执行一个简单的 HTTP 请求。在 r.header 我得到

{'date': 'Wed, 22 Jul 2015 06:30:12 GMT', 'content-length': '178', 'content-type
': 'text/html', 'connection': 'keep-alive', 'server': 'Mashape/5.0.6'}

在header我说应该returnjson。 return 是文本吗?对这个事实很困惑?一些见解会非常有帮助,因为我正在尝试做简单的

代码没有问题。

我已经通过访问来源检查了您的 API 上游请求:API 提供商的页面,看起来 API defunct/not 按预期工作。 这正是您收到错误的原因。 解决方案: 1) 联系供应商尝试解决问题,而不是你来解决问题 2) 从同一个门户中找到替代 API:https://www.mashape.com/explore?query=gender

祝你好运