如何获取从API生成的JSON列表并将其存储在Python中的哈希映射中



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

正在尝试写入以下代码:

result = c.get_quote("TSLA")
stockdatalist = []
stockdatalist.append(result)
print(stockdatalist)

输出:

[<Response [200]>]

我的期望:如何获取引号属性并将其存储到哈希图中?

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

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

最新更新