How do I convert RFC822 to a python datetime object?

前端 未结 3 1106
抹茶落季
抹茶落季 2020-12-25 14:07

I know how to do this the other way around... it would be:

>>> dt.rfc822()
\'Sun, 09 Mar 1997 13:45:00 -0500\'
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-25 14:52

    If you strip off the time zone, you can do it like this:

    datetime.datetime.strptime('Sun, 09 Mar 1997 13:45:00', '%a, %d %b %Y %H:%M:%S')
    

提交回复
热议问题