Python dateutil parser fails

限于喜欢 提交于 2019-12-12 14:40:15

问题


I am attempting to parse the 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?


回答1:


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




回答2:


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)


来源:https://stackoverflow.com/questions/6729902/python-dateutil-parser-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!