Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Dictionary str() method

Python Dictionary str() method

Python Dictionary Python Dictionary


Description

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

Syntax

str() method syntax:



str(dict)

Parameters

Return Value

Returns a string.

Example

The following example shows 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 Dictionary Python Dictionary