Python Requests模块-剥离内容

问题描述 投票:0回答:1

我正在尝试从下面指定的链接中调用Web请求(可能会有所不同,具体取决于您阅读本文时的情况),但是我只想要其中的特定部分,全都是一行。在"version":"12.30"部分中,我想保留12.30我需要使用什么代码?

LINK:https://fortnite-public-service-stage.ol.epicgames.com/fortnite/api/version

python python-3.x python-requests
1个回答
0
投票

您可以告诉请求模块,它应该将json字符串转换为字典,然后访问版本

url = "https://fortnite-public-service-stage.ol.epicgames.com/fortnite/api/version"
response = requests.get(url)
version = response.json()["version"]
© www.soinside.com 2019 - 2024. All rights reserved.