我正在阅读http://learnpythonthehardway.org/book/ex37.html但我不明白是什么//=
符号确实如此。/=
我感觉合理:
a = 9
a /= 3
a == 3 # => True
But //=
a = 9
a //= 3
a == 3 # => Also True
Thanks.
//
在python3中充当“整数除法”,看看这个答案.
在 C 中,除以/
对整数的作用相当于“下限除法”或“整数除法”。为了提供这种能力,python 提供了//
运算符,不同于/
这将给出浮点结果。
权威参考当然是pep-238.
从命令行版本(当你试图弄清楚这样的事情时很有用):
Python 3.2.3 (default, Apr 11 2012, ...
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 10
>>> a/3
3.3333333333333335
>>> a//3
3
>>>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)