String formatting (%)
Daniel 'Dang' Griffith
noemail at noemail4u.com
Thu Apr 29 07:59:45 EDT 2004
On Wed, 28 Apr 2004 09:15:02 -0400, Peter Hansen <peter at engcorp.com>
wrote:
>Pascal wrote:
>
>> Hello,
>> I've a float number 123456789.01 and, I'de like to format it like this
>> "123 456 789.01".
>> Is this possible with % character?
>
>No, as shown by http://docs.python.org/lib/typesseq-strings.html
>but you could probably use the 'locale' module instead.
>
>I suspect there's also a regular expression that could deal with
>that, but I don't want to know what it is. ;-)
>
>-Peter
Since you don't want to know what it is, I'll at least tell you
where it is: In Mastering Regular Expressions by Jeffrey E. F. Friedl.
I don't have it front of me, but it's the "commafying" example. A
quick search of the author's site looks like it's on pgs 64-65.
Of course, the OP would substitute spaces for the commas.
--dang
More information about the Python-list
mailing list