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
原文地址:https://www.cnblogs.com/dengyg200891/p/4945846.html