回复内容:
首先,如上面 @柯豪 的答案所说,Shell的行为并不完全和Python代码一致
>>> for i in range(5):
... i
...
0
1
2
3
4
Copy after login
这个例子非常有意思,无人邀请,我来答一下吧。
使用不熟悉的函数和library是危险的。
使用不熟悉的函数和library是危险的。
使用不熟悉的函数和library是危险的。
重要的话说三遍。
首先,先看这个例子,只是把helloworld.cpp 略加改动,题主觉得这个代码应当输出什么结果?
<span class="cp">#include <cstdio></span>
<span class="cp">#include <iostream></span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
<span class="p">{</span>
<span class="n">cout</span><span class="o"><<</span><span class="n">printf</span><span class="p">(</span><span class="s">"asdf"</span><span class="p">)</span><span class="o"><<</span><span class="n">endl</span><span class="p">;</span>
<span class="p">}</span>
Copy after login
主要是因为这东西变了.
主要是因为这东西变了.
而c库中的标准的输出没改变.
具体可以看这个文章
http:// eli.thegreenplace.net/2 015/redirecting-all-kinds-of-stdout-in-python/
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn