Python浮点数误差与解决方法&保留指定小数位数& 向上取整向下取整
参考:
Python浮点数误差与解决方法:
总结:
解决精度问题
方法一:Decimal(str(2.3))
方法二:getcontext
方法三:round四舍五入----------------------推荐用round!!!
注意:python中round函数的一个小坑——奇进偶弃:https://blog.****.net/xiaotao_1/article/details/81869350?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.control
保留小数位数:
https://blog.****.net/liuweiyuxiang/article/details/100574386
向上取整向下取整: