简体   繁体   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 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.

相关问题 如何从python的此列表中选取特定元素? - how can i take a specific element from this list in python? 如何将列表中的元素类型存储在 Python 的字典中? - How can I store the types of elements from a list in a dictionary in Python? 如何在 python 中将多个文件作为输入并存储在变量中 - How can I take multiple file as input in python & store in a variable 使用 ZA7F517F354216B63827 将 API 生成的嵌套 Json 数据存储到 SQL DB 中的最佳方法是什么 - What is the best way to store a nested Json data generated from API into SQL DB using Python 如何存储在Python中作为输出生成的数字列表? - How to store a list of numbers generated as output in Python? 如何从python的同一列表中获取不同长度的多个组合? - How can I take multiple combinations of the different lengths from the same list in python? 如何使用tkinter python获取文本文件并从中创建三重嵌套列表 - How can I take a text file and create a triple nested list from it with tkinter python 如何从SQL查询中提取单个列并将其添加到Python中的列表中 - How can I take a single column from a SQL query and add it to a list in Python 我如何告诉python从列表中的电子邮件中获取最后2个单词,但是不是python定义的列表,因为它发生了变化? - How can I tell python to take the last 2 words from an email that is in a list like structure but is not a list defined by python because it changes? 如何为 Swagger 生成的 python API 客户端设置超时? - How can I set a timeout for Swagger generated python API client?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM