擅长:python、mysql、java
<p>使用<code>datetime</code>模块。使用<code>.strptime()</code>将字符串转换为datetime对象,然后使用<code>.strftime()</code>转换为所需的字符串输出。示例datetime字符串表示为<code>'%b %d, %Y %H:%M:%S %p'</code></p>
<p><strong>例如:</strong></p>
<pre><code>import datetime
s = 'Jun 29, 2018 12:44:14 AM'
print( datetime.datetime.strptime(s, '%b %d, %Y %H:%M:%S %p').strftime("%H:%M:%S") )
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>12:44:14
</code></pre>