Python中的四舍五入和向下取整函数 在Python中进行程序编写时候,有时需要进行四舍五入,有时需要向下取整。这里有两个函数一个是python标准库中的函数round(),一个是扩展模块math中的math.floor(),这里分别介绍两个函数。 一、python中的四舍五入 round round(3.2) round(3.7) 举例运行 二、向下取整 math.floor import math math.floor(3.2) math.floor(2.9) 举例运行结果