1、int() 向下取整(内置函数)

python学习网,大量的免费python视频教程,欢迎在线学习!
n = 3.75 print(int(n)) >>> 3 n = 3.25 print(int(n)) >>> 3
相关推荐:《Python基础教程》
2、round() 四舍五入(内置函数)
n = 3.75 print(round(n)) >>> 4 n = 3.25 print(round(n)) >>> 3
3、floor() 向下取整(math模块函数)
floor的英文释义:地板。顾名思义也是向下取整
import math n = 3.75 print(math.floor(n)) >>> 3 n = 3.25 print(math.floor(n)) >>> 3
4、ceil()向上取整 (math模块函数)
ceil的英文释义:天花板。
import math n = 3.75 print(math.ceil(n)) >>> 4 n = 3.25 print(math.ceil(n)) >>> 4

售后响应及时
7×24小时客服热线
数据备份
更安全、更高效、更稳定
价格公道精准
项目经理精准报价不弄虚作假
合作无风险
重合同讲信誉,无效全额退款