擅长:python、mysql、java
<p><code>print >> sys.stderr</code>在Python3中消失了。
<a href="http://docs.python.org/3.0/whatsnew/3.0.html" rel="noreferrer">http://docs.python.org/3.0/whatsnew/3.0.html</a>说:</p>
<pre><code>Old: print >>sys.stderr, "fatal error"
New: print("fatal error", file=sys.stderr)
</code></pre>
<p>对我们中的许多人来说,把目的地降到命令的末尾有点不自然。另一种选择</p>
<pre><code>sys.stderr.write("fatal error\n")
</code></pre>
<p>看起来更加面向对象,并且优雅地从一般到特定。但是请注意<code>write</code>不是<code>print</code>的1:1替换。</p>