Home » str() in Python | Python str() Function with Examples

str() in Python | Python str() Function with Examples

by Online Tutorials Library

Python str() Function

Python str() converts a specified value into a string.

Signature

Parameters

object : It is the encoding of the object. The default value is UTF-8.

encoding : It is the encoding of the object. The default value is UTF-8.

errors : It specifies the actions that need to be performed if the decoding fails.

Return

It returns a string object.

Python str Function Example 1

The below example shows the working of str().

Output:

'4'  

Explanation: In the above example, we have taken a string value 4 in the str and returns a string ‘4’ as an output.


You may also like