[Apologies for the use of "reciprocity" in the subject - it's a little pompous, I know, but it fits so well. :)]

Hello c.l.python!

I'm trying to parse some dates of the form "01/29/09 12:55 PM" from a CSV file, but I'm having trouble with the format string in time.strptime() . In testing this I found that the time module chokes on a string that it created itself with the same format:

ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
Python 2.6.1 (r261:67515, Dec 5 2008, 13:58:38) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> fmt = "%m/%d/%y %I:%M %p"
>>> print time.strptime(fmt, time.strftime(fmt))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\_strptime.py", line 454, in _strptime_time
    return _strptime(data_string, format)[0]
  File "C:\Python26\lib\_strptime.py", line 325, in _strptime
    (data_string, format))
ValueError: time data '%m/%d/%y %I:%M %p' does not match format '02/16/09 04:52
PM'

So, yeah, that seems weird to me. Does anyone get similar results, know why this is happening, and/or how to fix it?

Thanks.

--
("%...@gmail com" % "Greg Krohn".lower()).replace(" ", ".")
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to