擅长:python、mysql、java
<>与其他语言(如C/C++)不同,分号是Python中语句的EM>可选EME>终结符,如下面的RePL中所见:</P>
<pre><code>Python 3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v
1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + 1;
2
>>> 1 + 1
2
</code></pre>
<p>但是,您可能会在IPython中观察到不同的行为:</p>
<pre><code>In [120]: 1 + 1;
In [121]: 1 + 1
Out[121]: 2
</code></pre>
<p>IPython的<a href="http://ipython.org/ipython-doc/dev/interactive/tips.html#suppress-output" rel="nofollow noreferrer">docs</a>建议使用分号来抑制输出。但是,这种行为只针对IPython,并没有以任何方式扩展到Python或其标准库(如doctest)。你知道吗</p>