Python3整数除法 [英] Python3 integer division

查看:148
本文介绍了Python3整数除法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python3和Python2.6中,我注意到我可以将两个整数相除并得到一个浮点数。如何恢复Python2.6的行为?

In Python3 vs Python2.6, I've noticed that I can divide two integers and get a float. How do you get the Python2.6 behaviour back? Is there a different method to get int/int = int?

推荐答案

尝试以下方法:

a = 1
b = 2
int_div  = a // b

这篇关于Python3整数除法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆