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

python之函数用法round()

时间:2015-11-07 19:04:25      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:

# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之函数用法round()
#http://www.cnblogs.com/hongfei/p/3858256.html



#round()
#说明:返回有N个小数点浮点数,
‘‘‘
round(...)
    round(number[, ndigits]) -> floating point number
    
    Round a number to a given precision in decimal digits (default 0 digits).
    This always returns a floating point number.  Precision may be negative.
‘‘‘



#案例
print round(3.1415926,3)#3.142
print round(3.1415926,2)#3.14
print round(3.1415926,10)#3.143.1415926
print round(100.000056, 3)#100.0
print round(-100.000056, 3)#-100.0

 

python之函数用法round()

标签:

原文地址:http://www.cnblogs.com/dengyg200891/p/4945846.html

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