python - 如何从 Json Url 中获取价值?
问题描述
我想从 json url 中获取 Value (BestPrice),如果它小于 250 - 做点什么!网址 = https://search.roblox.com/catalog/json?Category=2&SortType=2&ResultsPerPage=1
我已经尝试过 Aphid Il 发布我的代码
while True:
resp = requests.get(f"https://search.roblox.com/catalog/json?Category=2&SortType=2&ResultsPerPage=1")
data = json.loads(resp.text)
P = Aphid.findall(data, ['BestPrice'])
N = Aphid.findall(data, "Name")
S = Aphid.findall(data, "Sales")
print (f" {N} Tracking {P} R$ Sales - {S}")
if P < '250':
print("VALID")
我想得到 BestPrice 明确的数字,如果它小于 250 - 做点什么
解决方案
将代码的第二部分更改为:
P = data[0]['BestPrice']
N = data[0]['Name']
S = data[0]['Sales']
print (f" {N} Tracking {P} R$ Sales - {S}")
if P < '250':
print("VALID")
应该输出
Shaggy Tracking 375 R$ Sales - 2,127,365
推荐阅读
- python - 将数据传递给 Python multiprocessing.Pool 工作进程
- r - 如何使用嵌套的 for 循环优化我的 R 代码以更快地运行?
- android - NullPointerException - 当我尝试使用按钮切换活动时
- android - MPAndroidChart:LineChart 中来自 LiveData 的多个 LineDataSet
- javascript - 在评估 Promise.all 的结果时使用没有超时值的 setTimeout
- reactjs - 我应该把这段代码放在哪里,在反应应用程序中
- ios - Crashlytics vs Fabric vs Firebase 崩溃报告——我迷路了
- java - 将 Unix 时间戳转换为日期
- c# - 将 LINQ 中的表的月份格式转换为工作日格式
- django - 将 Excel 文件上传到 Django 时出现属性错误