[英]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 API: https://tda-api.readthedocs.io/en/latest/client.html#current-quotes
Attempting to write the following code:尝试编写以下代码:
result = c.get_quote("TSLA")
stockdatalist = []
stockdatalist.append(result)
print(stockdatalist)
Output: Output:
[<Response [200]>]
My Expectation: How can I take the quote attributes and store them into a hashmap?我的期望:如何获取报价属性并将它们存储到 hashmap 中?
In Python, you can use a data structure like Dictionary to store the values like in a 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.