如何在python中减少长度数字

如何在python中减少长度数字,python,numbers,int,Python,Numbers,Int,我必须将此值转换为23.69或23.70而不是像那个总数23.6909871246352 a=552.0 b=23.3 c=a/b print(c) str.format输出: print("{:.2f}".format(c)) 或圆形: round(c, 2) 输出: In [9]: print(c) 23.6909871245 In [10]: print("{:.2f}".format(c)) 23.69 In [11]: print(round(c, 2)) 23.69 使用圆

我必须将此值转换为
23.69
23.70
而不是像那个总数
23.6909871246352

a=552.0
b=23.3
c=a/b
print(c)

str.format
输出:

print("{:.2f}".format(c))
或圆形:

round(c, 2)
输出:

In [9]: print(c)
23.6909871245

In [10]: print("{:.2f}".format(c))
23.69
In [11]: print(round(c, 2))
23.69
使用圆函数-

c = round(a/b , 2)
两种方式: 圆形(a.b.2)

或仅用于显示,请使用以下命令:

>>> "%.2f" % 3.14159
'3.14'
>>> print("%.2f" % a)