Converting a floating point number to a string

Gerrit Holl gerrit at nl.linux.org
Sat Feb 26 15:41:22 EST 2000


On Sat, Feb 26, 2000 at 08:07:59PM +0000, kurtn at my-deja.com wrote:
> Hei
> As the subject says I would like to convert a
> floating point number to a string, in other words
> the opposite of 'atof'. I appreciate all the help
> I can get.

>>> str(1.5)
'1.5'

You can use the builtin 'str' function if you want to convert
_anything_ to a string: not only integers, lists, and dictionairies,
but also file objects and class instances. Please read the
documentation for more information.

regards,
Gerrit.

-- 
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----




More information about the Python-list mailing list