ホームページ >バックエンド開発 >Python チュートリアル >为什么python代码有时候在命令行下和Python Shell中执行的结果不一样呢 ?
<code class="language-text">>>> for i in range(5):
... i
...
0
1
2
3
4
</code>
这个例子非常有意思,无人邀请,我来答一下吧。<code class="language-cpp"><span class="cp">#include <cstdio></cstdio></span>
<span class="cp">#include <iostream></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 class="n">printf</span><span class="p">(</span><span class="s">"asdf"</span><span class="p">)</span><span class="o"><span class="n">endl</span><span class="p">;</span>
<span class="p">}</span>
</span></span></code>
主要是因为这东西变了.