zoukankan      html  css  js  c++  java
  • 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
    
    关注公众号 海量干货等你
  • 相关阅读:
    HDOJ_ACM_统计问题
    HDOJ_ACM_Queuing
    HDOJ_ACM_数塔
    HDOJ_ACM_免费馅饼
    HDOJ_ACM_FatMouse's Speed
    HDOJ_ACM_Monkey and Banana
    斐波南希数列
    .net framework 2.0的WinForm的ShowInTaskBar属性的bug
    寂寞的季节
    广告一下
  • 原文地址:https://www.cnblogs.com/sowhat1412/p/12734327.html
Copyright © 2011-2022 走看看