在Python 2中,两个整数的除法产生一个整数。在Python 3中,它产生一个浮点数。我们可以通过从中导入来获得新的行为
__future__。
>>> from __future__ import division>>> a = 4>>> b = 6>>> c = a / b>>> c0.66666666666666663

在Python 2中,两个整数的除法产生一个整数。在Python 3中,它产生一个浮点数。我们可以通过从中导入来获得新的行为
__future__。
>>> from __future__ import division>>> a = 4>>> b = 6>>> c = a / b>>> c0.66666666666666663