我不明白为什么我不能用 requests.Request() 得到 json 格式?

I dont get why I cant get a json format with requests.Request()?

from requests import Request as R

markets = R("GET", "https://ftx.com/api/markets")
print(markets.json())

错误: 打印(markets.json()) 类型错误:'NoneType' 对象不可调用

进程已完成,退出代码为 1

我想获得 json 的 HTTP 响应,但它不起作用,尽管它适用于 requests.get()。 请帮忙?

Request只是代表请求的对象。您希望 requests.request 构造 提出请求。

import requests

markets = requests.request("GET", "https://ftx.com/api/markets")

Request 对象的 json 属性将是请求的 JSON 负载,而不是 JSON 响应。

要使用 Request 对象手动发出请求,您需要先准备它,然后使用会话发送请求。例如,

markets = requests.Request("GET", "https://ftx.com/api/markets")
r = markets.prepare()
s = requests.Session()
result = s.send(r)
print(result.json())
example:

# import requests module
import requests
 
# Making a get request
response = requests.get('https://api.github.com')
 
# print response
print(response)
 
# print json content
print(response.json())