python使用正则表达式验证用户输入密码的有效性

Posted Data+Science+Insight

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python使用正则表达式验证用户输入密码的有效性相关的知识,希望对你有一定的参考价值。

python使用正则表达式验证用户输入密码的有效性

 

条件

1,最少有8位
2,字母范围a到z
3,至少有一个字母时大写的
4,至少有一个数字
5,至少有一个特殊字符(_、@、$)

#密码验证的条件

# Python program to check validation of password
# Module of regular expression is used with search()
import re
password = "R@m@_f0rtu9e$"
flag = 0
while True:
	if (len(password)<8):
		flag = -1
		bre

以上是关于python使用正则表达式验证用户输入密码的有效性的主要内容,如果未能解决你的问题,请参考以下文章