小编Man*_*nil的帖子

如何在python中格式化浮点数?

我想用小数点后两位数来格式化我的浮点数。

>>> x =5.0
>>> y=float("{:0.2f}".format(x))
>>> y
5.0
Run Code Online (Sandbox Code Playgroud)

我想要这种格式的输出:

5.00
Run Code Online (Sandbox Code Playgroud)

python format

6
推荐指数
2
解决办法
5638
查看次数

标签 统计

format ×1

python ×1