Python Dictionary keys() Method
Description
Python dictionary keys() function returns all the keys of a dictionary as a list.
Syntax
Syntax of the keys() method:
dict.keys()
Parameters
- NA。
Return Value
Returns all the keys of a dictionary.
Example
The following example demonstrates the usage of the keys() function:
Example
#!/usr/bin/python
tinydict = {'Name': 'Zara', 'Age': 7}
print "Value : %s" % tinydict.keys()
tinydict = {'Name': 'Zara', 'Age': 7}
print "Value : %s" % tinydict.keys()
The output of the above example is:
Value : ['Age', 'Name']Other Extensions
Python Dictionary