python之函数用法round()

# -*- 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

 

posted @ 2015-11-07 18:31  Xiao|Deng  阅读(826)  评论(0编辑  收藏  举报