繁体   English   中英

如何获取从 API 生成的 JSON 列表并将其存储在 hashmap 的 ZA7F5F35426B92784117369 中?

[英]How can I take a JSON List generated from an API and store that in a hashmap in Python?

API: https://tda-api.readthedocs.io/en/latest/client.html#current-quotes

尝试编写以下代码:

result = c.get_quote("TSLA")

stockdatalist = []

stockdatalist.append(result)

print(stockdatalist)

Output:

[<Response [200]>]

我的期望:如何获取报价属性并将它们存储到 hashmap 中?

在 Python 中,您可以使用像Dictionary这样的数据结构来存储 hashmap 中的值:

quote_dict = {}
stockdatadict = {}

for quote in quotes:
    result = c.get_quote(quote)
    stockdatadict[quote] = result
print(stockdatadict)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM