str()
function is used to find the the “informal” or nicely printable representation of a given object in Python for the given input.
str()
function is a part of Python Built-in Functions.
Syntax of str()
Function
The syntax of
str()
function in Python is:
str(object='') str(object=b'', encoding='utf-8', errors='strict')
Parameters of str()
Function in Python
x
– Where x
is any valid . This parameter is required.
Compatibility
str()
function is available and compatible with both Python 2.x
and 3.x
.
Return Value of str()
Function in Python
str()
function returns the “informal” or nicely printable representation of a given object for the given input.
Python str()
Function Example 1
Example CODE
Output:
Python str()
Function Example 2
Example CODE
Output: