exponential float formmating
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri Sep 7 09:42:30 EDT 2007
On Fri, 07 Sep 2007 06:08:19 -0700, zunbeltz wrote:
> For compatibility reasons with an old program I have to format string
> in exponential format with the following format
>
> 0.xxxxxE-yy
>
> This means that the number start always by 0 and after the exponent
> there should be alway the sing and 2 number for the exponent.
>
> for example 13 shoud be 0.13000E+02
> I always get 1.30000E001
I don't know if this is platform dependent but this works for me:
In [41]: '%e' % 1.3
Out[41]: '1.300000e+00'
In [42]: ('%e' % 1.3).upper()
Out[42]: '1.300000E+00'
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list