Web Analytics

Python str() Function

Type Conversion String

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

Syntax

str(object, encoding=encoding, errors=errors)

Parameters

Parameter Description
object Required. The object to convert into a string
encoding Optional. The encoding of the object. Default is UTF-8
errors Optional. Specifies what to do if the decoding fails

Return Value

A string version of the object.

Example

Using the str() function:

Output
Click Run to execute your code

Related Functions