converting ISO8601 date and time string representations to datetime
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Thu Jul 31 05:11:33 EDT 2014
Hi,
I'm trying to convert ISO8601-compliant strings representing dates or
dates and times into datetime.datetime objects.
I tried using the strptime method, but the problem here is that I can
only specify one format argument, which can be used to parse either a
full date/time string or just a date string, but not both.
While I could just try parsing with one format, then catch the
ValueError in case it fails and try another format, it feels like there
should be a more elegant way to do this.
I do know about the dateutil package, but I'd prefer to stick to the
stdlib for this.
Any suggestions ?
Wolfgang
More information about the Python-list
mailing list