示例
print('%.2f' % 1.255)
# 1.25
print('{:.2f}'.format(1.2635))
# 1.26
print(format(1.235, '.2f'))
# 1.24
print(round(1.23456, 2))
# 1.23
标签:format,Python,浮点数,示例,保留,2f,print,小数位 From: https://blog.51cto.com/u_13567403/5732949
示例
print('%.2f' % 1.255)
# 1.25
print('{:.2f}'.format(1.2635))
# 1.26
print(format(1.235, '.2f'))
# 1.24
print(round(1.23456, 2))
# 1.23
标签:format,Python,浮点数,示例,保留,2f,print,小数位 From: https://blog.51cto.com/u_13567403/5732949