exponential float formmating

zunbeltz at gmail.com zunbeltz at gmail.com
Fri Sep 7 10:17:53 EDT 2007


On 7 sep, 15:42, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> 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

I am working in windows I get
>>> '%e' % 13
'1.300000e+001'

In all cases I need the number to start with 0
0.13000E+01




More information about the Python-list mailing list