首页 > 解决方案 > 如何在python中将数字转换为整数

问题描述

我想知道如何在python 中1,999,999落地1,000,000或落地?我用过,但它只是为了删除小数部分。2,000,1082,000,000math.floor()

标签: pythonfloor

解决方案


这样做:

math.floor(num / 1000000) * 1000000

例如:

>>> num=1999999
>>> math.floor(num / 1000000) * 1000000
1000000.0
>>> num=2000108
>>> math.floor(num / 1000000) * 1000000
2000000.0

推荐阅读