import re
import json
# 将语句中不符合手机号码规则的数字串剔除,保存剩余符合手机号码规则的数字到ns中
def is_phone(n):
ns = re.findall('\d+', n) # 提取出word语句中的数字
new_list = ns[:] # 拷贝提取出的数字
for i in new_list:
if re.match(r'0?(13|14|15|17|18|19)[0-9]{9}', i): # 判断是否符合普通11位规则的手机号码
# print("正确的手机号:", i)
i
elif re.match("^((\\+86)|(86))?[1][3456789][0-9]{9}$", i): # 判断是否符合+86规则的手机号码
# print("正确的手机号:", i[2:15])
ns.remove(i)
ns.append(i[2:15])
else:
# print("错误的手机号:",i)
ns.remove(i)
return ns
# 匹配手机归属地字典,获取需要的信息,并将其按一定格式保存到dics中
def read_Number(n):
number = open("手机归属地字典.txt", 'r', encoding='utf-8') # 读取字典
lines = number.readlines()
dic = []
# 遍