【发布时间】:2010-01-07 10:33:25
【问题描述】:
今天,Python 的//“整数除法”运算符让我感到惊讶:
>>> math.floor(11/1.1)
10.0
>>> 11//1.1
9.0
documentation 读作“x 和 y 的(地板)商”。那么,为什么 math.floor(11/1.1) 等于 10,而 11//1.1 等于 9?
【问题讨论】:
-
Python 2-vs-3 除法差异的规范问题是How can I force division to be floating point in Python? Division keeps rounding down to 0
标签: python python-3.x python-2.x integer-division floor