擅长:python、mysql、java
<p>在python中,可以使用rfc822模块。此模块提供<a href="http://docs.python.org/library/rfc822.html#rfc822.parsedate">parsedate</a>方法。在</p>
<blockquote>
<p>Attempts to parse a date according to the rules in RFC 2822.</p>
</blockquote>
<p>但是,此模块已被<strong>弃用</strong>。在</p>
<blockquote>
<p>Deprecated since version 2.3: The email package should be used in preference to the rfc822 module. This module is present only to maintain backward compatibility, and has been removed in 3.0.</p>
</blockquote>
<p>根据这个注释,最好使用<a href="http://docs.python.org/library/email.util.html#email.utils.parsedate">email.utils</a>模块中的<a href="http://docs.python.org/library/email.util.html#email.utils.parsedate">parsedate</a>方法。在</p>
<pre><code>email.utils.parsedate(date)
</code></pre>
<p>编辑:</p>
<p>示例代码:</p>
^{pr2}$
<p>输出(目前):</p>
<pre><code>31 days, 2 hours ago
</code></pre>