|
|
发表于 2016-7-10 17:48:49
|
显示全部楼层
round(number[, ndigits])
Return the floating point value number rounded to ndigits digits after the decimal point. If ndigits is omitted, it defaults to zero. Delegates to number.__round__(ndigits).
For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). The return value is an integer if called with one argument, otherwise of the same type as number.
---
round的返回值会选择最接近10的倍数的那个(也就是四舍五入);如果两边的数几率相等,那么会选择是偶数的那一个。(举个例子,round(0.5)和round(-0.5)都是0,round(1.5)就会是2),如果只传入一个参数,那么函数会返回一个整数,否则会返回指定参数同类的数。 |
|