首页 > 解决方案 > 如何验证手机号码是否正确?

问题描述

我有一个问题是否可以仅验证 Python 中的 python-phonenumbers ( https://github.com/daviddrysdale/python-phonenumbers ) 库中的手机号码。我写了代码:

list = [...] #list of numbers to check
country = "XX"
is_valid = []
x = 0
while x < len(list):
    try:
        is_valid.append(phonenumbers.is_valid_number(phonenumbers.parse(list[x], country)))
        x = x + 1
    except:
        is_valid.append("False")
        x = x + 1

它正在工作,但也将固定电话标记为有效。有没有办法排除这种情况?

标签: python

解决方案


推荐阅读