简体   繁体   中英

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

Attempting to write the following code:

result = c.get_quote("TSLA")

stockdatalist = []

stockdatalist.append(result)

print(stockdatalist)

Output:

[<Response [200]>]

My Expectation: How can I take the quote attributes and store them into a hashmap?

In Python, you can use a data structure like Dictionary to store the values like in a hashmap:

quote_dict = {}
stockdatadict = {}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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