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.
Live Demo#!/usr/bin/python dict = {'Name': 'Zara', 'Age': 7}; print "Equivalent String : %s" % str (dict)
When we run above program, it produces following result −
Equivalent String : {'Age': 7, 'Name': 'Zara'}
python_dictionary.htm
Advertisements