• python 判断号码是否可用(号码过滤)


    def delCustomer(customer):  # 返回两个 第一个用来标记是否可用,第二个标记号码
        f = open(AbnormalPhone,"r")
        src = f.readlines()
        f.close()
        abnormalSet = set()
        for line in src:
            phone = str(line.split("
    ")[0].strip())
            abnormalSet.add(phone)
    
        matchObj = re.match('0?1[3-9]d{9}$', customer)
        if (matchObj!=None): # 如果是手机号
            if len(customer) == 11: 
                return 1,customer
            elif len(customer) == 12: 
                return 1,customer[1:]
        else: #如果不是手机号
            matchObj = re.match('0(10|2d)', customer) # 区号是3位 customer[0:3], customer[3:]  区号,号码
            if (matchObj != None):
                if (len(customer[3:]) == 7 or len(customer[3:]) == 8) and customer not in abnormalSet:
                    return 1,customer
                else:
                    return 0,customer
    
            matchObj = re.match('0([3-9]d{2})', customer) # 区号是4位  customer[0:4], customer[4:]  区号,号码
            if (matchObj != None):
                if (len(customer[4:]) == 7 or len(customer[4:]) == 8) and customer not in abnormalSet:
                    return 1,customer
                else:
                    return 0, customer
    
            if (len(customer) == 7 or len(customer) == 8) and customer not in abnormalSet:
                return 1,customer
            else:
                return 0,customer
    
    关注公众号 海量干货等你
  • 相关阅读:
    在不申请第三方变量的情况下交换a和b
    指针(pointer)的使用
    数组和链表(arrary & linkedlist)
    Python的学习计划
    Python——函数
    Python——文件操作
    Python——深浅Copy
    我发现的新大陆——好用的~
    我发现的新大陆——好吃儿的
    我发现的新大陆——好玩儿的
  • 原文地址:https://www.cnblogs.com/sowhat1412/p/12734327.html
Copyright © 2020-2023  润新知