python-输出小数点后几位

a = 3
b = 10
c = a/b
#使用占位符
print("%.3f" %c)
#使用format
print('{:.3f}'.format(c))

结果:

猜你喜欢

转载自blog.csdn.net/weixin_43934631/article/details/129817260