摘要:
下文讲述Python代码中round()函数的功能说明,如下所示:
round()函数功能说明
round()函数功能:
用于返回浮点数对应的四舍五入值
round()函数语法:
round( x [, n] )
-------参数说明----
x:数值表达式。
n:数值表达式,表示从小数点位数
-------返回值说明----
返回浮点数x的四舍五入值
例:
Python round修饰符示例分享
>>> print (round(99.12345,2))
99.12
>>> print (round(99.12345,3))
99.123
>>> print (round(99.12345,4))
99.1235
>>> print (round(99.12345,5))
99.12345
>>> print (round(99.12345,6))
99.12345
>>> print (round(99.12345,7))
99.12345
>>> print (round(99.12345,0))
99.0
>>> print (round(99.12345,-1))
100.0
>>> print (round(99.12345,-2))
100.0
>>> print (round(99.12345,-3))
0.0