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:
my_dictionary.keys()
Practical example
In this example, we use keys()
method to get the list of my_dict
dictionary keys.
my_dict = {
"id": 1,
"name": "Tom",
"age": 25
}
result = my_dict.keys()
print(result) # dict_keys(['id', 'name', 'age'])
Output:
dict_keys(['id', 'name', 'age'])