python 访问php api,php返回json格式转换

原文链接:http://stackoverflow.com/questions/24069197/httpresponse-object-json-object-must-be-str-not-bytes

使用函数

def get_shuj(url):
nexmo_url= url
req = urllib.request.Request(nexmo_url)
response = urllib.request.urlopen(req)
result = json.loads(response.readall().decode(‘utf-8’))
return result

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据