将RFC 3339时间转换为标准Python时间戳 [英] Convert an RFC 3339 time to a standard Python timestamp

查看:2721
本文介绍了将RFC 3339时间转换为标准Python时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个简单的方法可以将 RFC 3339 转换为普通的Python时间戳?

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

我有一个正在读取ATOM Feed的脚本,我想能够将ATOM Feed中的项目的时间戳记与修改一个文件的时间。

I've got a script which is reading an ATOM feed and I'd like to be able to compare the timestamp of an item in the ATOM feed to the modification time of a file.

我从 ATOM规格,ATOM日期包括时区偏移( Z ),但在我的情况下,在 Z 之后没有什么,所以我想我们可以假设GMT。

I notice from the ATOM spec, that ATOM dates include a time zone offset (Z<a number>) but, in my case, there's nothing after the Z so I guess we can assume GMT.

我想我可以解析时间使用正则表达式,但我希望Python具有内置的方法,我只是无法找到。

I suppose I could parse the time with a regex of some sort but I was hoping Python had a built-in way of doing it that I just haven't been able to find.

推荐答案

没有内置的,afaik。

No builtin, afaik.

feed.date.rfc3339
这是一个Python库模块具有将RFC 3339格式的时间戳字符串转换为Python时间浮点值的功能,反之亦然。 RFC 3339是Atom供稿联合格式使用的时间戳格式。

feed.date.rfc3339 This is a Python library module with functions for converting timestamp strings in RFC 3339 format to Python time float values, and vice versa. RFC 3339 is the timestamp format used by the Atom feed syndication format.

是BSD许可的。

http://home.blarg.net/~steveha/pyfeed.html

(已编辑,所以很清楚我没有写。: - )

(Edited so it's clear I didn't write it. :-)

这篇关于将RFC 3339时间转换为标准Python时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆