校验邮箱
import redef validateEmail(email):if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) != None:print("成功")return Trueelse:print("失败")return TruevalidateEmail('123@abc.net.cn')
校验手机号
import redef main(tel):ret = re.match(r"^1[35678]\d{9}$", tel)if ret:print("成功")return Trueelse:print("失败")return Falseif __name__ == "__main__":main("15517520123")
OK.