如何使用python舍入一个浮点数? -钻石棋牌

round()python中的库函数四舍五入到指定位置的数量。以下是一些ê xamples

>>> round(11.6912,2) # upto second decimal place
11.69
>>> round(11.6912,1) # upto first place after decimal point
11.7
>>> round(11.6912) # rounded to nearest integer
12
>>> round(11.6912,-1)#rounded to ten's place
10.0

钻石棋牌的友情链接:

网站地图