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
无语言基础,自学python所做的各种笔记,欢迎大牛指点.