Pythonは、切り上げ切り捨て、機能を丸め

1. 向上取整

import math

f = 11.2
print math.ceil(f) #向上取整

out:12.0  # 返回结果是浮点型

2.丸めダウン

import math

f = 11.2
print math.floor(f) #向下取整

out: 11.0  #返回结果是浮点型

3.丸め

import math

f = 11.2
print round(f) #四舍五入

out: 11.0  #返回结果是浮点型

4.リファレンス

https://www.cnblogs.com/SZxiaochun/p/6961370.html

 

公開された38元の記事 98ウォンの賞賛 ビュー360 000 +

おすすめ

転載: blog.csdn.net/xijuezhu8128/article/details/88554887