擅长:python、mysql、java
<p>当然。有几种方法。在</p>
<ol>
<li><p>首先,您可以使用<code>md5.stdout.read()</code>,但是在那里您必须自己进行行分离。</p></li>
<li><p>然后,可以将file对象<code>md5.stdout</code>作为迭代器来操作。但是缓冲似乎有一个问题,也就是说,你不能立即得到结果。</p></li>
<li><p>然后有可能重复调用<code>md5.stdout.readline()</code>,直到它返回<code>''</code>。</p></li>
</ol>
<p>在这种情况下,第三种方法是首选的;我建议这样做:</p>
<p>。。。在</p>
<pre><code>for f in iter(md5.stdout.readline, ''):
fc = f.rstrip("\n")
sys.stdout.write("\rChecked " + fc)
sys.stdout.flush()
</code></pre>
<p>我还更改了输出文本,因为只有che che检查已经完成时才会有输出。在</p>
<p>如果这不是您想要的,而是将每个输出单独捕获,那么您应该切换到第1点。但这就更复杂了。我会考虑一个解决方案,只要表明它是需要的。在</p>
<p>在这方面,必须考虑以下几点:</p>
<ul>
<li><code>read()</code>块,因此应该逐字节读取(相当难看)。在</li>
<li>问题是什么应该输出,什么时候应该有间歇输出。在</li>
</ul>