1.为了控制输出的小数点的位数,可以使用format函数
eg:(python3)
print ('你是BMI是:{:.2f}'.format(BMI))
是的没有错。
原表见https://blog.csdn.net/weixin_35674012/article/details/78196054
2.为了使输出的几行数字对齐,可以使用format函数,使每个数字占固定的几个格
eg:(python3)
print("{:3d}".format(n))
或者:
print(format(n,'3d'),end=' ')
是的和%3d一样,占三格,d代表以整数形式输出。