python --百位千位向上下取整
class MathFloor(object):'''向下取整'''__params = {1: 1, 2: 10, 3: 100, 4: 1000, 5: 10000, 6: 100000}@classmethoddef floor_number(cls, value: int or float) -> int:'''向下取整'''result = 0if isinstance(value
·
class MathFloor(object):
'''向下取整'''
__params = {1: 1, 2: 10, 3: 100, 4: 1000, 5: 10000, 6: 100000}
@classmethod
def floor_number(cls, value: int or float) -> int:
'''向下取整'''
result = 0
if isinstance(value, float):
result = int(value)
for k, v in cls.__params.items():
if len(str(value)) == k:
result = math.floor(int(value) / v) * v
return result
更多推荐
已为社区贡献15条内容
所有评论(0)