Python中的舍入规则

Spa*_*ter 0 python rounding

我想在python中找到一些不同的规则.例如;

10.666 = 10.6
10.667 = 10.7
Run Code Online (Sandbox Code Playgroud)

即6点,7点.

有没有办法可以用Python做到这一点?

S.L*_*ott 5

使用decimal.Decimal.它内置和调试了各种复杂的舍入规则.

http://docs.python.org/library/decimal.html