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
    
    关注公众号 海量干货等你
  • 相关阅读:
    MySQL重置密码
    linux下自动备份脚本并上传到ftp服务器
    nginx配置
    WIFI防蹭网
    无线路由知识
    009汇编环境搭建
    008 计算机不会加法
    007计算机不会做加法
    006源码反码补码
    005有符号数和无符号数
  • 原文地址:https://www.cnblogs.com/sowhat1412/p/12734327.html
Copyright © 2011-2022 走看看