2025年4月5日 星期六 乙巳(蛇)年 正月初六 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > Python

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

时间:05-20来源:作者:点击数:

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

  • #手机号码校验
  • 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

 

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门