擅长:python、mysql、java
<p>根据您的Python版本,您可以:</p>
<p>对于<code>Python 3.6</code>和以后的版本,请使用新的<code>format-strings</code>,这是<strong>最推荐的方法:</p>
<pre><code>row = [u'28d07ef48e40', u'373ac79f615f', u'a3ec4faddbec', u'c0195f9568c6', u'cc4ebc7b826c', u'ccdfdb826c', u'cc4fa826c', u'cc4eeesb826c', u'ccfesb826c']
fw.write(f'{row[0]} {row[1]} [{row[2]}] ...')
</code></pre>
<p>对于Python 3的较低版本,可以使用<code>str.format()</code>,这是<strong>推荐的<code>%</code>格式:</p>
<pre><code>fw.write('{} {} <{}> [{}] {} {} ({}) {}: {}'.format(row[0], row[1], row[2], ...)
</code></pre>
<p>对于Python 2,您可以继续使用<code>%</code>格式,但不需要对参数调用<code>str()</code>,这是自动完成的:</p>
<pre><code>fw.write("%s %s <%s> [%s] %s %s (%s) %s: %s" % tuple(row))
</code></pre>