擅长:python、mysql、java
<p>在Python 3.0中,<code>5 / 2</code>将返回<code>2.5</code>,<code>5 // 2</code>将返回<code>2</code>。前者是浮点除法,后者是floor除法,有时也称整数除法。</p>
<p>在Python 2.2或更高版本的2.x行中,整数没有区别,除非执行<code>from __future__ import division</code>,这会导致python2.x采用3.0的行为</p>
<p>不管将来的导入如何,<code>5.0 // 2</code>都将返回<code>2.0</code>,因为这是操作的楼层划分结果。</p>
<p>您可以在<a href="https://docs.python.org/whatsnew/2.2.html#pep-238-changing-the-division-operator" rel="noreferrer">https://docs.python.org/whatsnew/2.2.html#pep-238-changing-the-division-operator</a>找到详细说明</p>