day5_判断价格输入是否是正整数或正小数

def check_float_integer(s):  #判断价格正确的正整数或正小数
    s = str(s)
    if check_integer(s) == True:
        return True
    elif s.count('.') == 1:
        s_split = s.split('.')
        left,right = s_split
        if left.isdigit() and right.isdigit():
            if int(right) > 0:  #整数部分大于0
                return True
    return False
def check_integer(s): #判断数量是正整数
    s = str(s)
    if s.isdigit(): #判断是否是大于等于0的整数
        if int(s) > 0:
            return True
    return False

 

posted on 2018-09-14 07:07  羽竹  阅读(262)  评论(0编辑  收藏  举报