Python:删除十进制除法 [英] Python: Remove division decimal

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

问题描述

我已经制作了一个将数字相除然后返回数字的程序,但问题是,当它返回数字时,它具有一个小数,例如:

I have made a program that divides numbers and then returns the number, But the thing is that when it returns the number it has a decimal like this:

2.0

但我希望它能给我:

2

在此先感谢!

推荐答案

您可以在最终结果上调用 int()

You can call int() on the end result:

>>> int(2.0)
2

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

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