Sunday, April 5, 2015

str() - Python Tutorial

str() built-in function



 


str() Built-in Function


str() is a built-in function in Python that will convert an other type like a integer, float, list, tuple and so on to a string.


Str() Syntax


syntax(argument)


The argument can be a integer, floating point number, list, tuple, dictionary, file, and so on.  The argument will be converted to a string.


str() Built-in Function Examples


#Str() Built-in Function

>>> str(6)
'6'
>>> str(7.6)
'7.6'
>>> str((6,75,9))
'(6, 75, 9)'
>>> str('cat': 'mary', 'dog': 'maggie')
"'cat': 'mary', 'dog': 'maggie'"

If you have any questions about the str() built-in function leave a comment below and we will do our best to assist you.


No comments:

Post a Comment