数据api,我需要从购买中获取价值,只输出数据,我查了字典什么也没有

Data api, I need to take the value from buys, only data is output, i check dictionary and nothing

请帮忙api,我把所有东西都放在照片里了,我需要从 买了,不知道怎么做,只输出数据

import requests
import json
def get_depth(limit=50):
    response = requests.get(url="...")
    with open("depth.txt", "w") as file:
        file.write(response.text)
data = requests.get("...").text
data = json.loads(data)
for items in data["data"]["buys"]:
    price = items ["price"]
    print("data")
print("data")
def main():
    print(get_depth())
if __name__ == "__main__":
    main()

[my code][https://i.stack.imgur.com/yAQfP.png]
[data][https://i.stack.imgur.com/Po87U.png]
[list][https://i.stack.imgur.com/ObZVM.png]
[result][https://i.stack.imgur.com/lQHIy.png]

您正在打印字符串“data”而不是变量本身。

您需要使用 print(data)

无论如何,要获得购买价格,您需要像这样更改循环。

for item in data["data"]["buys"]:
    price = item["price"]
    print(price)

如果您注意到我删除了 print(data),因为它会用您从网络服务获取的所有数据淹没您的屏幕。