Python str() Function
ExampleGet your own Python Server
Convert the number 3.5 into an string:
x =
str(3.5)
Try it Yourself »
Definition and Usage
The str() function converts the specified
value into a string.
Syntax
str(object, encoding=encoding, errors=errors)
Parameter Values
| Parameter | Description |
|---|---|
| object | Any object. Specifies the object to convert into a string |
| encoding | The encoding of the object. Default is UTF-8 |
| errors | Specifies what to do if the decoding fails |
More Examples
Related Pages
Tutorial: Python Strings