获取浮点数的整数和小数部分

>>> a=123.3232
>>> math.modf(a)
(0.32319999999999993, 123.0)

小数位数较多,可以使用round

如:

>>> round(0.32319999999999993,4)
0.3232
原文地址:https://www.cnblogs.com/sea-stream/p/10201267.html