如何在 Python 中将 RFC 822 时间戳转换为人类可读的格式?
有谁知道 Python 模块可以将 RFC 822 时间戳转换为人类可读的格式(就像 Twitter 那样)?
我发现 parsedatetime ,它似乎起到了相反的作用。
Does anyone know of a Python module that will convert an RFC 822 timestamp into a human readable format (like Twitter does) in Python?
I found parsedatetime, which seems to do the reverse.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在Python中,您可以使用rfc822模块。该模块提供了 parsedate 方法。
但是,此模块已弃用。
根据此评论,最好使用 parsedate 方法href="http://docs.python.org/library/email.util.html#email.utils.parsedate">email.utils 模块。
编辑:
示例代码:
输出(目前):
In python, you can use rfc822 module. This module provides the parsedate method.
However, this module is deprecated.
According to this comment, it's better to use the parsedate method from the email.utils module.
EDIT:
Example code :
Output (for now) :
datetime.strptime
会将时间戳转换为日期时间对象,您可以使用datetime.strftime
对其进行格式化http://docs.python.org/library/datetime.html#strftime-strptime-behavior
datetime.strptime
will turn the times stamp into a datetime object which you can format withdatetime.strftime
http://docs.python.org/library/datetime.html#strftime-strptime-behavior
请参阅
http://docs.python.org/library/rfc822.html#rfc822。解析日期
See
http://docs.python.org/library/rfc822.html#rfc822.parsedate