x=3.1191y=2.3432z=0.897g = float("{0:.2f}".format(x))e = float("{0:.2f}".format(y))f = float("{0:.3f}".format(z))print g,e,f
第一种方法:x = round(x,3)第二种方法:x = {0:.3f}".format(x)第三种方法:print('%5.3f' % x)
a=float(input())print("{:.2g}".format(a))