标准库:内置函数—round(number[,a])
样例:
>>> import math
>>> x = math.pi
>>> x
3.141592653589793
>>> round(x,3)
3.142
>>> round(x)
3
>>>
round(number[,a])用法介绍
- 返回 number 舍入到小数点后 a 位精度的值。
- a省略时number舍入到整数
参考链接:
Python 标准库>>内置函数
样例:
>>> import math
>>> x = math.pi
>>> x
3.141592653589793
>>> round(x,3)
3.142
>>> round(x)
3
>>>
round(number[,a])用法介绍
参考链接:
Python 标准库>>内置函数