Microsoft-style format strings

Mike Fletcher mfletch at tpresence.com
Mon May 22 12:24:30 EDT 2000


See the time module's strftime documentation for more general formatting of
dates.  For the formatting of currency, see posts from sometime this month
(see dejanews) regarding locales.  For general string formatting, see the
string formatting section of the docs (2.1.5.1).

import time
time.strftime( '%a %d-%b-%Y', time.gmtime( time.time()))

HTH,
Mike

...
"Andy Robinson" <andy at reportlab.com> escribió en el mensaje
news:PGECLPOBGNBNKHNAGIJHAEADCCAA.andy at reportlab.com...
> Has anybody written anything analogous to the
> VB-style format function?
>
> This would be able to do
>    format("$#,##0.00", someAmount)
> or
>    format("ddd dd-mmm-yyyy", someDate)
>
> Hoping-to-save-an-hour-or-two-ly y'rs,
>
> Andy Robinson
>




More information about the Python-list mailing list