In python 2.x, dividing two integers returns an integer. However, if you use
from ___future___ import division
you can get a float value:
>>> 3/2
1
>>> from __future__ import division
>>> 3/2
1.5
>>>
>>>
>>> 3//2
1
>>> 4/3
1.3333333333333333
>>>
After the import
, you have to use //
instead of /
to do integer division. How can I revert the import
so that /
does integer division again?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…