On Mon, Aug 22, 2011 at 11:48:46AM +0200, Peter Otten wrote: > przemol...@poczta.fm wrote: > > >>>> import locale > >>>> locale.setlocale(locale.LC_ALL, "pl_PL") > > 'pl_PL' > >>>> i=0.20 > >>>> j=0.25 > >>>> locale.format('%f', i) > > '0,200000' > >>>> locale.format('%f', j) > > '0,250000' > > > > I need to print the numbers in the following format: > > '0,2' (i) > > '0,25' (j) > > So the last trailing zeros are not printed. > > >>> print locale.format("%g", 1.23) > 1,23 > >>> print locale.format("%g", 1.2345678) > 1,23457 > >>> print locale.format("%.10g", 1.2345678) > 1,2345678 > >>> print locale.format("%.15g", 0.1) > 0,1 > >>> print locale.format("%.17g", 0.1) > 0,10000000000000001
Thank you very much :-) Regards Przemyslaw Bak (przemol) ---------------------------------------------------------------- Znajdz samochod idealny dla siebie! Szukaj >> http://linkint.pl/f2a0a -- http://mail.python.org/mailman/listinfo/python-list