[BangPypers] HELP ON FORMATING OUTPUT

Sribabu rusticgeek at gmail.com
Sat Mar 22 08:15:33 CET 2008


Hi Jiten

I have probably a easier way via an import.
here you go:

import locale

def number_format(number, grouping=0):
return locale.format("%.*f", (grouping, number), True)

regards,
Sri

On Sat, Mar 22, 2008 at 2:10 AM, Nanolets nanolets <srini at nanolets.in>
wrote:

> A stupid way to do this is
>
> x=123456789
> x=str(x)
> n=len(x)
> s=n%3
> outs=x[0:s]
> while ( s < n) :
>        outs = outs + "," + x[s:s+3]
>        s=s+3
> print outs
>
>
> On 3/19/08, Jiten Shah <jiten_shah_78 at yahoo.com> wrote:
> >
> > Dear Friends,
> >
> > I am new for python and new for this mailing list also
> >
> > My problem is i want to print
> >    1156179 to ->   1,156,179.00
> >
> > Can somebody help me.
> >
> >
> > Jiten
> >
> >
> >
> >
> >
> >
> >       ____________________________________________________________________________________
> > Be a better friend, newshound, and
> > know-it-all with Yahoo! Mobile.  Try it now.
> > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
>
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/bangpypers/attachments/20080322/1f0e2eea/attachment.htm 


More information about the BangPypers mailing list