Converting a floating point number to a string

Carel Fellinger cfelling at
Sun Feb 27 22:18:32 CET 2000

kurtn at wrote:
> As the subject says I would like to convert a
> floating point number to a string, in other words

other pointed you in the direction of the simple "str" call, but if
more control over the layout is needed you might use the "%" trickery like:

>>> '%5.2f' % 123.4567
>>> '%5.2e' % 123.4567

have fun

groetjes, carel

More information about the Python-list mailing list