在Python中,你可以使用requests
库来发送HTTP请求,并获取接口的返回值。下面是一个简单的示例:
import requests# 发送GET请求response = requests.get('https://api.example.com/users')# 获取接口返回的JSON数据data = response.json()# 打印返回值print(data)
在上面的示例中,我们发送了一个GET请求到https://api.example.com/users
接口,并将返回的数据解析为JSON格式。你可以根据实际情况来发送不同类型的请求(如POST、PUT等),并按需解析返回的数据。