python round四舍五入的问题

python 里3.15  round(3.15,1)=3.1

print(round(3.15,1))
decimal.getcontext().rounding=decimal.ROUND_HALF_UP
b=decimal.Decimal('3.15',decimal.getcontext())
print(round(b,1))

posted on 2018-09-20 16:13  mojiemeizi  阅读(448)  评论(0编辑  收藏  举报