蟒蛇的格式,只有1小数点后一位
>>> "{0:0.1f}".format(45.34531)
'45.3'
蟒蛇的格式小数
# 2.6 python and newer and python 3.x
# Put desired number of decimal by changing the number inside {:.2f} bellow;
print(' {:.2f}'.format(71.428571))
71.43
# 2.6 python and older
# Put desired number of decimal by changing the number inside '%.2f' bellow;
print('%.2f'%(71.428571))
71.43