PHP前端开发

python中round啥意思

百变鹏仔 1个月前 (01-17) #Python
文章标签 啥意思
Python 中的 round() 函数用于将数字四舍五入到指定的位数。功能包括:将数字四舍五入到小数点后指定位数。如未指定位数,则四舍五入到整数。

何谓 Python 中的 round

Python 中的 round() 函数用于将数字四舍五入到指定的位数。

功能

语法

立即学习“Python免费学习笔记(深入)”;

round(number, ndigits=0)

其中:

示例

>>> round(3.14159)3>>> round(3.14159, 2)3.14>>> round(1000000.0, -3)1000000.0

注意事项