(no subject)

Skip Montanaro skip at pobox.com
Thu Jun 5 15:08:03 EDT 2003


 
    Mark> i have a date, say as a string 26Nov2002 and i want to convert it
    Mark> to a string 20021126.

Python has a time module with strptime (parse) and strftime (format)
functions.

>>> import time
>>> t = time.strptime("26Nov2002", "%d%b%Y")  
>>> t
(2002, 11, 26, 0, 0, 0, 1, 330, -1)
>>> time.strftime("%Y%m%d", t)
'20021126'

Skip





More information about the Python-list mailing list