+ 2

What is the use of str in python?

???

28th Aug 2021, 11:44 AM
Vishal Mourya
Vishal Mourya - avatar
16 Answers
+ 2
The str() function of Python returns the string version of the object. Syntax: str(object, encoding=’utf-8?, errors=’strict’) Parameters: object: The object whose string representation is to be returned. encoding: Encoding of the given object. errors: Response when decoding fails. Returns: String version of the given object # Python program to demonstrate # strings    # Empty string s = str() print(s)    # String with values s = str("GFG") print(s)
28th Aug 2021, 4:34 PM
Arun Jamson
Arun Jamson - avatar
+ 6
Vishal Mourya In python function str() is used to convert the specified value into a string.
28th Aug 2021, 11:47 AM
Khentit Nadji Sabri
+ 2
Thanks
28th Aug 2021, 11:48 AM
Vishal Mourya
Vishal Mourya - avatar
+ 2
Vishal Mourya str is a short name of string which is a function in python which takes 1 parameter. number = 10 string = str(number) Now number is converted into string, you can check using type function like this : print(type(string)) https://code.sololearn.com/cam8v49qqQ41/?ref=app
28th Aug 2021, 12:06 PM
A͢J
A͢J - avatar
+ 2
Thanks
28th Aug 2021, 12:07 PM
Vishal Mourya
Vishal Mourya - avatar
+ 2
Vishal Mourya check my shared code
28th Aug 2021, 12:08 PM
A͢J
A͢J - avatar
+ 2
In python, str is an object (string), its a set of characters and it has a lot of functions. You can use it for eg. str(20) -> "20" str([20, 40]) -> "[20, 40]" For more info you can try this: help(str)
28th Aug 2021, 5:45 PM
Sousou
Sousou - avatar
+ 2
str refers to string is a sequence of character enclosed in either single quotes double quotes or triple quotes
29th Aug 2021, 8:58 AM
Vaishnavi Gupta
+ 2
In python str() is used to convert a particular value into string type.
29th Aug 2021, 9:10 AM
Utkarsh Gautam
+ 2
str() in pythn convert any value to string Example Num = 5 // now its an integer you can test it print(type(Num)) Num2 = str(Num) print(type(Num2)) // u see the dff
29th Aug 2021, 10:11 AM
bakeery
+ 1
Thanks
28th Aug 2021, 11:45 AM
Vishal Mourya
Vishal Mourya - avatar
+ 1
Thank you
29th Aug 2021, 3:16 AM
Vishal Mourya
Vishal Mourya - avatar
+ 1
It's give output in string format
29th Aug 2021, 6:05 AM
144 Riya Singh
144 Riya Singh - avatar
+ 1
Thanks to all
29th Aug 2021, 5:11 PM
Vishal Mourya
Vishal Mourya - avatar
0
In python how to use str,int in one program
8th Dec 2022, 7:11 AM
Sai Tammu
Sai Tammu - avatar