开发者

Python dateutil parser fails

I am attempting to parse the开发者_Go百科 following date strings obtained from email headers:

from dateutil import parser
d1 = parser.parse('Tue, 28 Jun 2011 01:46:52 +0200')
d2 = parser.parse('Mon, 11 Jul 2011 10:01:56 +0200 (CEST)')
d3 = parser.parse('Wed, 13 Jul 2011 02:00:01 +0000 (GMT+00:00)')

The third one fails; am I missing something obvious?


have you tried parser.parse('...', fuzzy=True)? (I suppose it works :))


Give a try to parsedatetime library.

In [16]: import parsedatetime.parsedatetime as pdt

In [17]: p = pdt.Calendar()

In [18]: p.parse("Wed, 13 Jul 2011 02:00:01 +0000 (GMT+00:00)")
Out[18]: ((2011, 7, 20, 0, 0, 0, 2, 201, -1), 3)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜