Latest web development tutorials

Python dictionary (Dictionary) str () method

description

Python dictionary (Dictionary) str () function to translate the value suitable for human readable, printable string representation.

grammar

str () method syntax:

str(dict)

parameter

  • dict - dictionary.

return value

Returns a string.

Examples

The following example shows str () function to use:

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7};
print "Equivalent String : %s" % str (dict)

The above example output is:

Equivalent String : {'Age': 7, 'Name': 'Zara'}