擅长:python、mysql、java
<p>将日期字符串分析为datetime.datetime。由于日期字符串没有年份、月份或日期,因此datetime将假定日期为<code>1900-1-1</code>。如果我们减去<code>datetime.datetime(1900,1,1)</code>,我们将得到一个<code>datetime.timedelta</code>对象,它有一个<a href="https://docs.python.org/2/library/datetime.html#datetime.timedelta.total_seconds" rel="nofollow">^{<cd4>} method</a>。转换为分钟很容易:</p>
<p>从中减去</p>
<pre><code>import datetime as DT
t1 = DT.datetime.strptime('00:05:36.0100000', '%H:%M:%S.%f0')
t2 = DT.datetime(1900,1,1)
print((t1-t2).total_seconds() / 60.0)
</code></pre>
<p>收益率</p>
<pre><code>5.60016666667
</code></pre>