a = 1
b = 3
print(a/b)
#方法一:
print(round(a/b,2))
#方法二:
print(format(float(a)/float(b),'.2f'))
#方法三:
print ('%.2f' %(a/b))
python 除法保留两位小数点
最新推荐文章于 2024-08-08 16:43:27 发布
a = 1
b = 3
print(a/b)
#方法一:
print(round(a/b,2))
#方法二:
print(format(float(a)/float(b),'.2f'))
#方法三:
print ('%.2f' %(a/b))