Convert number to string in python

By: Python Documentation Team  

To convert, e.g., the number 144 to the string ‘144’, use the built-in type constructor str(). If you want a hexadecimal or octal representation, use the built-in functions hex() or oct(). For fancy formatting, see the String Formatting section, e.g. "{:04d}".format(144) yields '0144' and "{:.3f}".format(1/3) yields '0.333'.




Archived Comments

1. Brettkip
View Tutorial          By: Brettkip at 2017-07-31 13:06:53


Most Viewed Articles (in Python )

Latest Articles (in Python)

Comment on this tutorial