0
Could someone explain to me what does "str" mean and what does it do? Thanks! :)
2 ответов
+ 1
You can use str to type cast. and you can convert something (a float or integer) to string type.
e.g. lets say you have an integer type variable ...
>>> enrollment_number= 32
>>> str(enrollment_number)
'32'
try it on your idle.
Note: vice versa isn't possible for a string type variable. because strings cannot be converted into integer or float.
try this as well.
>>> iLike= 'Python'
>>> int(iLike)
you will get an error....
>>> float(iLike)
you will get an error again......
Hope this helps... Thank you and Happy Programming. :)
0
As far as I can tell, it converts one variable of any type into a string.