Python str() function
Python str() function
The str() function in Python converts the specified value into a string.
Syntax
class str(object='')
or
class str(object=b'', encoding='utf-8', errors='strict')
Parameter
object: This parameter represents any object to convert the given object into a string
encoding: It performs the encoding of the object, and by default, its value is UTF-8
errors: This parameter specifies what to do if the decoding fails
Return
This function returns a str version of object.
Example 1
# Python programing explaining # the str() function val = str(33.5) # prininting the string value print(val)
Output
33.5