Python Dictionary str() method
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
- dict -- the dictionary.
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
}
;
"Equivalent String : %s"
%
str
(
tinydict
)
The output of the above example is:
Equivalent String : {'Age': 7, 'Name': 'Zara'}
Python Dictionary