擅长:python、mysql、java
<p>如果你像我一样沉迷于Python 2.4系统:</p>
<pre><code>from time import strptime
from datetime import datetime
str_to_datetime = lambda st: datetime(*strptime(st, '%Y-%m-%d %H:%M:%S')[:6])
str_to_datetime('2010-04-20 10:07:30')
</code></pre>
<p>否则datetime.strtime()就可以正常工作了。</p>