>>> import email.utils as eut
>>> eut.parsedate('Wed, 23 Sep 2009 22:15:29 GMT')
(2009, 9, 23, 22, 15, 29, 0, 1, -1)
如果需要datetime.datetime
对象,可以执行以下操作:
def my_parsedate(text):
return datetime.datetime(*eut.parsedate(text)[:6])
如何在Python中解析HTTP日期字符串?
>>> import email.utils as eut
>>> eut.parsedate('Wed, 23 Sep 2009 22:15:29 GMT')
(2009, 9, 23, 22, 15, 29, 0, 1, -1)
如果需要datetime.datetime
对象,可以执行以下操作:
def my_parsedate(text):
return datetime.datetime(*eut.parsedate(text)[:6])