我有两个整数值a和b,但我需要他们的浮点比例.我知道a < b并且我想要计算a / b,所以如果我使用整数除法,我将总是得到0,余数为a.
a
b
a < b
a / b
我如何c在Python中强制成为Python中的浮点数?
c
c = a / b
python floating-point integer division python-2.x
使用一个比另一个有好处吗?在Python 2中,它们似乎都返回相同的结果:
>>> 6/3 2 >>> 6//3 2
python math syntax operators
python ×2
division ×1
floating-point ×1
integer ×1
math ×1
operators ×1
python-2.x ×1
syntax ×1