round()

round() 用于对一个数值进行四舍五入,如果接收两个参数,则第二个参数表示保留多少位小数

In [1]: round(1.5324)   
Out[1]: 2.0

In [2]: round(1.5324, 2) 
Out[2]: 1.53

    

猜你喜欢

转载自www.cnblogs.com/pzk7788/p/10263281.html