擅长:python、mysql、java
<p><strong>现在在Python>;=3.3</strong>中,您只需调用<a href="http://docs.python.org/3.3/library/datetime.html#datetime.datetime.timestamp" rel="noreferrer">timestamp() method</a>即可将时间戳作为浮点数获取。</p>
<pre><code>import datetime
current_time = datetime.datetime.now(datetime.timezone.utc)
unix_timestamp = current_time.timestamp() # works if Python >= 3.3
unix_timestamp_plus_5_min = unix_timestamp + (5 * 60) # 5 min * 60 seconds
</code></pre>