Skip to main content
 首页 » 编程设计

python之如何在 python 中格式化 float

2025年05月04日22findumars

<分区>

我想用小数点后 2 位格式化我的 float 。

>>> x =5.0 
>>> y=float("{:0.2f}".format(x)) 
>>> y 
5.0 

我想要这种格式的输出:

5.00