One - One Code All

Blog Content

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

Python   2010-06-17 21:02:32
import math

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

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



上一篇:python遍历字典并修改,错误:dictionary changed size during iteration
下一篇:pandas根据索引获取数据,索引检索再追加isin

The minute you think of giving up, think of the reason why you held on so long.