Skip to content

保留小数的方法 ​

python
round()
round(3.14159, 2)  # 结果: 3.14
:.2f
price = 3.14159
print(f"{price:.2f}")  # 结果: 3.14