欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python 正则匹配手机号

程序员文章站 2023-04-07 21:14:21
import rephone = str(input('请输入手机号:'))# b = str(12345678912)t = re.compile(r'^1(3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8[0-9]|9[0-9])\d{8}$')s = re.searc... ......
import re
phone = str(input('请输入手机号:'))
# b = str(12345678912)
t = re.compile(r'^1(3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8[0-9]|9[0-9])\d{8}$')
s = re.search(t,phone)
# print(s)
if s:
print(s.group(),'是正常手机号')
else:
print('手机号格式不正确')

python 正则匹配手机号