#正则表达式判断邮箱格式是否正确
# 分析:[a-zA-Z0-9_]@[a-zA-Z0-9].[a-zA-Z]
while 1:
import re
email=input("请输入邮箱:")
# patten=re.compile("^[a-zA-Z0-9]@[a-zA-Z0-9].[a-zA-Z]$")
result=re.findall("^[a-zA-Z0-9_]+@[a-zA-Z0-9]+.[a-zA-Z]+$",email)
if result:
print("邮箱格式正确")
else:
print("邮箱格式错误")
匹配密码:
#密码:任意字符 6-16
while 1:
import re
pass2 = input("请输入密码:")
result=re.findall("^.{2,4}$",pass2)
if result:
print("pass")
else:
print("fail")