[Tutor] Converting month names to abbreviated form

David Rock david at graniteweb.com
Mon Jul 26 01:43:52 CEST 2004


* Tim Peters <tim.peters at gmail.com> [2004-07-24 23:10]:
> [Gus Tabares]
> > Are there any known routines for converting month names to their
> > abbreviated form (i.e., December->Dec) ?
> 
> If you're thinking about American month names, the abbreviation of a
> month name is just its first 3 letters.
> 
> >>> 'December'[:3]
> 'Dec'
> >>> 'January'[:3]
> 'Jan'
> >>>

I believe the strftime module will let you get this information.
Specifically, you want the %b format specifier. 
http://docs.python.org/lib/module-time.html#l2h-1765


-- 
David Rock
david at graniteweb.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20040725/2ff3043c/attachment.pgp


More information about the Tutor mailing list