簡體   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