python 手机号码 邮箱 身份证校验

时间:2021-08-17 10:34:35   收藏:0   阅读:15
#手机号码校验
import re
while True:
    iphone = input(‘请输入手机号码:‘).strip()
    res = re.match("1[35678]\d{9}", iphone)
    #res = re.match("1[3-9]\d{9}", iphone)
    if res:
        print(iphone)
        break


#邮箱校验
import re
while True:
    email = input(‘请输入邮箱:‘).strip()
    res = re.match("\w+@\w+\.\w+", email, re.ASCII)
    if res:
        print(email)
        break

#身份证校验
import re
while True:
    text = input(‘请输入身份证号码:‘).strip()
    res = re.findall("\d{17}[\dX]", text)
    if res:
        print(text)
        break

原文:https://www.cnblogs.com/simon1993/p/15150328.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!