Python <Response [200]>>的<绑定方法Response.json

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36240495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 17:36:29  来源:igfitidea点击:

<bound method Response.json of <Response [200]>>

python

提问by cyber8200

I trying to make a request GET to https://randomuser.me/api/

我试图向https://randomuser.me/api/发出请求

import requests
import json


url = "https://randomuser.me/api/"
data = requests.get(url).json

print data


I kept getting

我不断得到

# <bound method Response.json of <Response [200]>>

How do I see the json response ? Something like this

我如何查看 json 响应?像这样的东西

{
    "results": [
        {
            "user": {
                "gender": "female",
                "name": {
                    "title": "ms",
                    "first": "kerttu",
                    "last": "tervo"
                },
                "location": {
                    "street": "9102 aleksanterinkatu",
                    "city": "eurajoki",
                    "state": "pirkanmaa",
                    "zip": 67561
                },
                "email": "[email protected]",
                "username": "silvercat709",
                "password": "papa",
                "salt": "tOCPX2GL",
                "md5": "86c60371eeb94596916d66cee898c869",
                "sha1": "d06c4f2e43f8c0e53d88e538655f1152169ce575",
                "sha256": "5a6b011841b27b08c38d2091dfb3d7ca50f55192ca0fcf6929dae098316c9aae",
                "registered": 1419602511,
                "dob": 1266822680,
                "phone": "03-479-964",
                "cell": "047-950-61-69",
                "HETU": "220210A290R",
                "picture": {
                    "large": "https://randomuser.me/api/portraits/women/68.jpg",
                    "medium": "https://randomuser.me/api/portraits/med/women/68.jpg",
                    "thumbnail": "https://randomuser.me/api/portraits/thumb/women/68.jpg"
                }
            }
        }
    ],
    "nationality": "FI",
    "seed": "7d24284202c2cfdb06",
    "version": "0.8"
}

回答by xio

Actually you should call it (since there is method).

实际上你应该调用它(因为有方法)。

data = requests.get(url).json()