Python Str() function

Published February 17, 2022

In Python, the str() method is used to convert a given value into a string

Syntax of str() method
The str() method is written as follows:

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

 

where:
object: encoding object
encoding: encoding of the object
errors: actions taken if decoding does not work


Example
 

x= "I Love Python"
a = str(x)
print(a)


Output

I Love Python

 

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

324 Views