浮点数保留n位小数

p = 1.234
p = round(p,2) 
print(p) # 1.23

#round(你要操作的数,保留几位)

原文地址:https://www.cnblogs.com/liangying666/p/9161711.html