Convert an RFC 3339 time to a standard Python timestamp

后端 未结 14 1897
Happy的楠姐
Happy的楠姐 2020-12-03 04:40

Is there an easy way to convert an RFC 3339 time into a regular Python timestamp?

I\'ve got a script which is reading an ATOM feed and I\'d like to be able to compar

14条回答
  •  心在旅途
    2020-12-03 05:32

    feedparser.py provides robust/extensible way to parse various date formats that may be encountered in real-world atom/rss feeds:

    >>> from feedparser import _parse_date as parse_date
    >>> parse_date('1985-04-12T23:20:50.52Z')
    time.struct_time(tm_year=1985, tm_mon=4, tm_mday=12, tm_hour=23, tm_min=20,
                     tm_sec=50, tm_wday=4, tm_yday=102, tm_isdst=1)
    

提交回复
热议问题