python中取整数的多种方法

1:向下取整用int()  

a=0.37 

int(a)

-->3

2:四舍五入时用round()

a=0.37

round(a)

-->4

3:向上取整有2中方法

①:向下取整后+1

②:应用math模块  如

import math#调用math模块

a=0.37

math.ceil(a)

-->4

posted @ 2018-06-22 14:46  我不会python  阅读(423)  评论(0编辑  收藏  举报