parsing a date

Kalle Anke skromta at gmail.com
Fri Sep 23 15:37:42 EDT 2005


I want to parse a date string, for example '2005-09-23', and since I haven't 
done this before I would like to ask what is the best way to do it.

I've looked around and the dateutil seems to be what most people use, but 
unfortunately I only get an empty file when I try to download it. I also 
tried the standard modules and ended up with this

import datetime
from time import strptime

d = '2005-09-23'
w = strptime(d,'%Y-%m-%d')
print datetime.date( w[0], w[1], w[2] )

But I suspect there is a better way to do it??




More information about the Python-list mailing list