Python dictionary str() Method
Advertisements
Description
The method str() produces a printable string representation of a dictionary.
Syntax
Following is the syntax for str() method
str(dict)
Parameters
dict -- This is the dictionary.
Return Value
This method returns string representation.
Example
The following example shows the usage of str() method.
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7};
print "Equivalent String : %s" % str (dict)
Let us compile and run the above program, this will produce the following result:
Equivalent String : {'Age': 7, 'Name': 'Zara'}