处理小数

# coding=utf-8
# Time : 2021-08-01
# Author : wangkaiyu


# 保留一位小数
def deal_with_float(num, n):
    num = str(num)
    a, b, c = num.partition(".")
    c = c[:n]
    return float(".".join([a, c]))


# 去除小数点
def del_point(num):
    num = str(num)
    a, b, c = num.partition(".")
    return int(a)
posted @ 2021-08-03 13:50  等杰伦下课  阅读(52)  评论(0编辑  收藏  举报