The string is a data type used to express data in a human-readable format with characters. Also, there are different types used to store data in different ways like a number, integer, floating-point, byte, etc. The str() method is the most popular and easy way to convert different types into strings.
str() Method Sytanx
The defacto way to convert any type of value into the string is using the str() method. Even the parameter can be an integer, float, etc. in this case we are interested in converting from integer to string.
str(OBJECT)
- OBJECT can be a value which is integer, float etc. This parameter is required.
Convert Integer To String
An integer type which can be an integer variable or integer value can be converted into the string by using the str() method.
a = 5
five = str(a)
five = str(5)
Convert Floating Point Into String
A floating-point type which can be a floating-point variable or floating-point value can be converted into the string by using the str() method.
a = 5.5
v = str(a)
v = str(5.5)
Convert Byte Into String
A byte type which can be a byte variable or byte value can be converted into the string by using the str() method.
a = b'I like pythontect.com'
s = str(a)
s = str(b'I like pythontect.com')