round(1.23, 1)
1.2
round(1.27, 1)
1.3
round(-1.27, 1)
-1.3
round(1.25361,3)
1.254
格式化输出:0.2f
x = 1.23456
format(x, '0.2f')
'1.23'
format(x, '0.3f')
'1.235'
'value is {:0.3f}'.format(x)
'value is 1.235'
round(1.23, 1)
1.2
round(1.27, 1)
1.3
round(-1.27, 1)
-1.3
round(1.25361,3)
1.254
x = 1.23456
format(x, '0.2f')
'1.23'
format(x, '0.3f')
'1.235'
'value is {:0.3f}'.format(x)
'value is 1.235'