Python str() function

Python str() function

The str() function in Python converts the specified value into a string.

Syntax

          or

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

Output