码迷,mamicode.com
首页 > 编程语言 > 详细

Python函数-round() 函数

时间:2017-05-31 17:34:38      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:表达式   span   round   int   style   函数   bin   0.00   pre   

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

 

 

Python函数-round() 函数

标签:表达式   span   round   int   style   函数   bin   0.00   pre   

原文地址:http://www.cnblogs.com/guyuyuan/p/6925010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!