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