擅长:python、mysql、java
<p>如果不想手动四舍五入,只需切掉微秒的最后三位数:</p>
<pre><code>def format_time():
t = datetime.datetime.now()
s = t.strftime('%Y-%m-%d %H:%M:%S.%f')
return s[:-3] `def format_time():
t = datetime.datetime.now()
s = t.strftime('%Y-%m-%d %H:%M:%S.%f')
return s[:-3]
</code></pre>