[Tutor] String Formatting
orbitz
orbitz at ezabel.com
Fri Sep 10 17:54:00 CEST 2004
Your choices then are most likely either using regexp or manually doing it.
Isr Gish wrote:
>Thanks orbitz,
>
>But...
>
> >oldloc = locale.setlocale(locale.LC_ALL)
> >locale.setlocale(locale.LC_ALL, 'en_US')
> >locale.format('%d', some_num, True)
> >locale.setlocale(locale.LC_ALL, oldloc)
> >
>
>I would rather not use this way, iit takes about 25 times longer then a regular % format. And I'm using it for about 1,000,000 times.
>
>Isr
>
>-----Original Message-----
> >From: "orbitz"<orbitz at ezabel.com>
> >Sent: 9/9/04 10:55:22 PM
> >To: "Isr Gish"<isrgish at fastem.com>, "tutor at python.org"<tutor at python.org>
> >Subject: Re: [Tutor] String Formatting
> >
> >Easiest way would probably be using locale.format in some code I do:
> >
> >oldloc = locale.setlocale(locale.LC_ALL)
> >locale.setlocale(locale.LC_ALL, 'en_US')
> >locale.format('%d', some_num, True)
> >locale.setlocale(locale.LC_ALL, oldloc)
> >
> >
> >Isr Gish wrote:
> >
> >>Hi,
> >>
> >>How can I format a integer in a format string with a comma for example
> >>print 'Your Account has %f' %amount
> >>That should print:
> >>Your Account has 1,000.00
> >>
> >>Thanks
> >>Isr
> >>
> >>_______________________________________________
> >>Tutor maillist - Tutor at python.org
> >>http://mail.python.org/mailman/listinfo/tutor
> >>
> >>
> >>
> >
>
>
>
>
More information about the Tutor
mailing list