<p><code>datetime.strptime</code>是将字符串解析为日期时间的主要例程。它可以处理各种格式,格式由您提供的格式字符串决定:</p>
<pre><code>from datetime import datetime
datetime_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p')
</code></pre>
<p>生成的<code>datetime</code>对象是时区原始对象。</p>
<p>链接:</p>
<ul>
<li><p>Python文档<code>strptime</code>:<a href="https://docs.python.org/2/library/datetime.html#datetime.datetime.strptime" rel="noreferrer" title="datetime.datetime.strptime">Python 2</a>,<a href="https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime" rel="noreferrer">Python 3</a></p></li>
<li><p>Python文档中的<code>strptime</code>/<code>strftime</code>格式字符串:<a href="https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior" rel="noreferrer" title="strftime-and-strptime-behavior">Python 2</a>,<a href="https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior" rel="noreferrer">Python 3</a></p></li>
<li><p><a href="http://strftime.org/" rel="noreferrer">strftime.org</a>也是strftime的一个很好的参考资料</p></li>
</ul>
<p>注:</p>
<ul>
<li><code>strptime</code>=“字符串分析时间”</li>
<li><code>strftime</code>=“字符串格式时间”</li>
<li>今天大声说出来,6个月后就不用再找了。</li>
</ul>