简体   繁体   English

访问列表的索引元素,其中列表是python字典的值

[英]Accessing indexed element of a list, where the list is a value of a python dictionary

i Have a dictionary where the values are list, i have something like this:我有一个字典,其中的值是列表,我有这样的东西:

dic = {"A":[6,4,7,10], "B":[8,10,90,100]}

how do i access the element 7 from the list where the key is "A"?如何从键为“A”的列表中访问元素 7?

只需添加一个额外的索引,如dic['A'][2]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 访问给定键的列表值的第n个元素:Python字典 - Accessing nth Element of a list value for a given key: Python dictionary 更新列表的一个元素,其中列表是字典中的一个值 - Update an element of a list, where list is a value in dictionary 如何修改列表中的特定元素(取决于另一个字典),其中列表是字典的值? (Python) - How can I modify a specific element(which depends on another dictionary) in a list, where the list is the value of a dictionary? (python) python 按值对字典进行排序,其中每个元素都是一个列表(按列表中的第一个元素) - python sort dictionary by value where each element is a list (by the first element in the list) 搜索其中值是列表的Python词典 - Search Python dictionary where value is list 创建一个 python 字典,其中值是字符串列表 - create a python dictionary where the value is a list of strings 如何对字典进行排序,其中值是python中的列表 - How to sort dictionary where value is a list in python Python:将列表转换成字典,其中key是列表元素的索引 - Python: Convert list to a dictionary, where key is the index of the element of the list Python 访问字典列表中的值,如果字典中存在另一个值 - Python Accessing a Value in a List of Dictionaries, if another Value in the Dictionary Exists 访问列表中的字典中的值 - Accessing the value in a dictionary that is inside a list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM