其他分享
首页 > 其他分享> > 密码强度判断

密码强度判断

作者:互联网

import string
password = input("请输入密码:")
strength, digits, lower, upper, punctuation = 0,0,0,0,0
for c in password :
if c in string.digits:
digits = 1
elif c in string.ascii_lowercase:
lower = 1
elif c in string.ascii_uppercase:
upper = 1
elif c in string.punctuation:
punctuation = 1
if len(password) < 8:
strength = 0
else:
strength = digits+lower+upper+punctuation
if strength < 2:
print("弱")
elif strength == 2:
print("中")
elif strength == 3:
print("强")
elif strength == 4:
print("极强")

 

 

标签:digits,upper,elif,判断,string,强度,密码,strength,print
来源: https://www.cnblogs.com/lzw2019114243036/p/15339563.html