python - 如何验证手机号码是否正确?
问题描述
我有一个问题是否可以仅验证 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
它正在工作,但也将固定电话标记为有效。有没有办法排除这种情况?
解决方案
推荐阅读
- pandas - pandas 根据特定列创建交叉验证
- reactjs - 使用 React 处理跨不同导出的事件
- javascript - 创建新数组与在反应中修改相同的数组
- c# - 从另一个表单更新 dataGridView 值
- java - 正则表达式在Java中跨多行的2个其他单词之间查找单词而不是其他单词
- django - 发送到不同队列的芹菜任务不起作用
- android - Android Studio 突然打不开模拟器
- algorithm - 如何通过分而治之来解释 min-max 中的非整数比较次数?
- c# - 在 ASP .NET Core MVC 中的 Web API 参数中传递加号和空格
- database - 在 PostgreSQL 数据库表中实现具有 100 多列的高性能搜索的最佳方法是什么?