擅长:python、mysql、java
<p>我认为<code>strftime()</code>不会直接支持<code>%f</code>。不过,记录器提供毫秒作为单独的毫秒<a href="https://docs.python.org/2/library/logging.html?highlight=msec#logrecord-attributes" rel="noreferrer">attribute</a>,因此您可以在现有时间戳之后自己添加它,如下所示:</p>
<pre><code>logging.basicConfig(format='%(asctime)s.%(msecs)03d %(levelname)s {%(module)s} [%(funcName)s] %(message)s', datefmt='%Y-%m-%d,%H:%M:%S', level=logging.INFO)
</code></pre>
<p>这给了我以下使用脚本的输出:</p>
<pre><code>2015-07-10,09:21:16.841 INFO {test script} [get_started2] Logged2 Here
</code></pre>