- 捨棄小數部分
>>> math.trunc(12.533222)
12 post
>>> round(12.2544)
12blog
也能夠:class
int(12.0)=12di
- 按給定小數位數四捨五入
>>> round(12.2544, 3)
12.254math
- 向上取整
>>> math.ceil(12.4584)
13
- 向下取整
>>> math.floor(12.4584)
12
>>> math.trunc(12.533222)
12 post
>>> round(12.2544)
12blog
也能夠:class
int(12.0)=12di
>>> round(12.2544, 3)
12.254math
>>> math.ceil(12.4584)
13
>>> math.floor(12.4584)
12