round( x [, n] )功能: round() 方法返回浮点数x的四舍五入值。 x-数值表达式。n-数值表达式。返回浮点数x的四舍五入值。 实例:
1 #!/usr/bin/python 2 3 print "round(80.23456, 2) : ", round(80.23456, 2) 4 print "round(100.000056, 3) : ", round(100.000056, 3) 5 print "round(-100.000056, 3) : ", round(-100.000056, 3)
结果:
round(80.23456, 2) : 80.23 round(100.000056, 3) : 100.0 round(-100.000056, 3) : -100.0
时间: 2024-11-08 23:31:06