Python str() function
The str() function in Python converts the specified value into a string.
Syntax
1 2 3 |
class str(object='') |
or
1 2 3 |
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
1 2 3 4 5 6 7 |
# Python programing explaining # the str() function val = str(33.5) # prininting the string value print(val) |
Output
1 2 3 |
33.5 |