开发者

Python 2.5 fails on a datetime.strptime format

I have seen several questions with people asking about the same problem but none of the answers are helping me.

I'm receiving this error:

    pydev debugger: starting
Traceback (most recent call last):
>>>
  File "/usr/local/zend/apache2/htdocs/pyth/src/conn.py", line 23, in <module>
    userConnDate = datetime.strptime(data[1] + ' ' + data[2], "%y-%m-%d %H:%M:%S")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/_strptime.py", line 330, in strptime
    (data_stri开发者_运维技巧ng, format))
ValueError: time data did not match format:  data=2010-03-11 08:35:25  fmt=%y-%m-%d %H:%M:%S

It looks fine to me, what is python seeing that I don't?

Thanks for you time.


you are using %y (which matches a 2 digit year).
try with %Y, which matches a 4 digit year (like your 2010)


Try using the a capital Y - '%Y' to match a 4-digit year.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜