EN
Python - get dictionary items
3 points
In this article, we would like to show you how to get dictionary items in Python.
Quick solution:
xxxxxxxxxx
1
my_dictionary.items()
In this example, we use items()
method to get the list of my_dict
dictionary items.
xxxxxxxxxx
1
my_dict = {
2
"id": 1,
3
"name": "Tom",
4
"age": 25
5
}
6
result = my_dict.items()
7
8
print(result) # dict_items([('id', 1), ('name', 'Tom'), ('age', 25)])
Output:
xxxxxxxxxx
1
dict_items([('id', 1), ('name', 'Tom'), ('age', 25)])