2021-04-08
方法一:format函数
>>> print('{:.3f}'.format(1.23456))
1.235
>>> print(format(1.23456, '.2f'))
1.23
方法二:’%.xf’
>>> print('%.2f' % 1.23456)
1.23
方法三:round()函数
>>> print(round(1.23456,3))
1.235
>>> print(round(2.355,2
原创
2021-04-08 20:25:19 ·
45 阅读 ·
0 评论