Python 之 向上取整、向下取整以及四舍五入函数

import math

f = 11.2
print math.ceil(f) #向上取整
print math.floor(f) #向下取整
print round(f) #四舍五入

#这三个函数的返回结果都是浮点型

 

posted @ 2017-06-08 10:02  那一剑的風情  阅读(79867)  评论(0编辑  收藏  举报