[英]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.