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