700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > python正则表达式——验证密码邮箱

python正则表达式——验证密码邮箱

时间:2019-11-30 23:58:29

相关推荐

python正则表达式——验证密码邮箱

Python正则表达式指南

今天看了下正则,就随意写了个验证密码邮箱是否合格,写的很简单

1、密码需要由大写、小写、数字三部分组成,并且不能短于八位

2、邮箱组成:***@***.**即可

def checkMail(mail):pattern = pile(r'(\w+)@\w+\.(com|cn|org)')m = pattern.match(mail)if m:return m.group(1)else:return Nonedef checkContainNumber(pwd):pattern = pile(r'\d+')return len(pattern.findall(pwd)) > 0def checkContainLower(pwd):pattern = pile('[a-z]+')return len(pattern.findall(pwd)) > 0def checkContainUpper(pwd):pattern = pile('[A-Z]+')return len(pattern.findall(pwd)) > 0def checkLen(pwd):pattern = pile(r'\w{8,}')return pattern.match(pwd) is not Nonedef checkPwd(pwd):return checkLen(pwd) and checkContainUpper(pwd) and checkContainLower(pwd) and checkContainNumber(pwd)while(1):mail = raw_input("plz input mailAddress : ")name = checkMail(mail)if name is None:print "plz input mail again"continueelse:print "%s is mail name" % namepwd = raw_input("plz input password : ")print checkPwd(pwd)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。