目录
round方法
对浮点数后的小数位数进行处理,第一个参数是一个浮点数,第二个参数是保留的小数位数,可选,如果不写的话默认保留到整数。
BMI=20.957438
BMI=round(BMI,1)
print(BMI)
运行结果:
注意:round的结果跟python版本有关
阅读一下python的文档,里面是这么写的:
在python2.7的doc中,round()的最后写着,"Values are rounded to the closest multiple of 10 to the