Python手机号码查运营商

def test():
    while True :

        numbers = input('请输入你的手机号码 :')
        CN=[134,135,136,137,138,139,150,151,152,157,158,159,182,
        183,184,187,188,147,178]
        CN_union = [130,131,132,155,156,185,186,145,176,179]
        CN_telecom = [133,153,180,181,189,177]
        nums = int(numbers[0:3])

        if len(numbers)==11 :
            
            if nums in CN :
                print('您的号码属于:中国移动')

            elif nums in CN_union:
                print('您的号码属于:中国联通')
            elif nums in CN_telecom :
                print('您的号码属于:中国电信')

            else :
                print('您输入的号码查不到归属运营商')

        else :
            print('输入错误,请输入11位数字')
test()

你可能感兴趣的:(Python手机号码查运营商)