我对python非常陌生,我正在尝试从API中提取特定数据
例如,我想提取3y_夏普比。我试过:
import requests
import json
VTI = requests.get("https://eodhistoricaldata.com/api/fundamentals/VTI.US?api_token=OeAFFmMliFG5orCUuwAKQ8l4WWFQ67YX").json()
print(VTI["3y_SharpRatio"])
但收到以下错误:
KeyError
Traceback (most recent call last) <ipython-input-7-4dc0323003b9> in <module>
----> 1 print(VTI["3y_SharpRatio"])
KeyError: '3y_SharpRatio'
欢迎任何帮助,如果这是一个非常基本的问题,请道歉
您在文章中包含了您的API密钥,从安全角度来看这是不好的,但确实允许我看到
3y_SharpRatio
在这里:所以你需要
我已经注释掉了几行,你可以用它们一步一步地挖下去找到你的钥匙
相关问题 更多 >
编程相关推荐