擅长:python、mysql、java
<p>唯一不使用<code>print</code>的尾随逗号(或者使用Py3/<code>from __future__ import print_function</code>的<code>end</code>关键字参数)的方法是,您必须一次完成所有打印操作-ie:</p>
<pre><code>while ...:
# calulating value1 and value2
# calulating value3 and value4
print '%10d %10s %7s %15d' % (value1, value2, value3, value4)
</code></pre>
<p>如果这使可读性成为一个问题,请考虑将计算逻辑放入函数中,以便执行以下操作:</p>
<pre><code>while ...:
value1 = calculate_value1()
value2 = calculate_value2()
value3 = calculate_value3()
value4 = calculate_value4()
print '%10d %10s %7s %15d' % (value1, value2, value3, value4)
</code></pre>