擅长:python、mysql、java
<p><a href="https://hg.python.org/cpython/file/tip/Lib/_strptime.py#l298" rel="noreferrer">^{<cd1>} is implemented in pure Python</a>。与<code>strftime()</code>不同的是,[支持哪些指令]不依赖于平台。<code>%z</code>受支持,因为Python 3.2:</p>
<pre><code>>>> from datetime import datetime
>>> datetime.strptime('24/Aug/2014:17:57:26 +0200', '%d/%b/%Y:%H:%M:%S %z')
datetime.datetime(2014, 8, 24, 17, 57, 26, tzinfo=datetime.timezone(datetime.timedelta(0, 7200)))
</code></pre>
<blockquote>
<p>how to parse Email time zone indicator using strptime() without being aware of locale time?</p>
</blockquote>
<p>Python2.7中没有具体的时区实现。您可以很容易地实现UTC偏移解析,请参见<a href="https://stackoverflow.com/a/23122493/4279">How to parse dates with -0400 timezone string in python?</a></p>