200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > python使用正则表达式判别用户输入密码的强弱并提示

python使用正则表达式判别用户输入密码的强弱并提示

时间:2019-10-30 23:09:28

相关推荐

python使用正则表达式判别用户输入密码的强弱并提示

python使用正则表达式判别用户输入密码的强弱并提示

对于用户输入的密码、系统要去分析和判别,密码是否合法是否太简单以至于非常容易被试出来,来提高系统的稳健程度;

密码要强大需要满足:

1,最好9个字符最多20个字符

2,不能是换行或者空格

3,不能连续出现统一字符

4,字符模式不能重复出现(字符模式指的是至少两个字符构成的组合反复出现)

#Categorize Password as Strong or Weak using Regex in Python

# Categorizing password as Strong or# Weak in Python using Regeximport re# Function to categorize passworddef password(v):# the password should not be a# newline or spaceif v == "\n" or v == " ":return "Password cannot be a newline or space!"# the password length should be in# between 9 and 20if 9 <= len(v) <= 20:# checks for occurrence of a character# three or more times in a rowif re.search(r(.)\1\1, v):re

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