除法在Python 2.7中。和3.3我如何在Python2.7中除以两个数字,然后用小数得到结果?我不明白为什么会有区别:在Python 3中:>>> 20/151.3333333333333333在Python 2中:>>> 20/151这不是个模组吗?
3 回答

aluckdog
TA贡献1847条经验 获得超7个赞
/
from __future__ import division
>>> 7 / 23>>> from __future__ import division>>> 7 / 23.5>>>
//
%
>>> 7 % 21>>> 7 // 23>>>
编辑
user2357112

慕哥9229398
TA贡献1877条经验 获得超6个赞
/
/
int
//
20.
float(20)
)
添加回答
举报
0/150
提交
取消