Python Dictionary str() Method

Python 字典Python Dictionary


Description

The Python Dictionary str() function converts a value into a human-readable form, represented as a printable string.

Syntax

The syntax of the str() method is:

str(dict)

Parameters

  • dict -- A dictionary.

Return Value

Returns a string.

Example

The following example demonstrates how to use the str() function:

Example

#!/usr/bin/python

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

The output of the above example is:

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

Python 字典Python Dictionary

Other Extensions