def password_score(password):
score = 0
if len(password) < 6:
return score
score += 1
has_sz = has_xx = has_dx = has_ts = False
for c in password:
if has_sz is False and c in '1234567890':
score += 1
has_sz = True
if has_xx is False and c in 'abcdefghijklmnopqrstuvwxyz':
score += 1
has_xx = True
if has_dx is False and c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
score += 1
has_dx = True
if has_ts is False and c in '~!@#$%^&*()_+':
score += 1
has_ts = True
score += len(set(password)) // 6
return score
if __name__ == '__main__':
password = input('请输入密码:')
score = password_score(password)
if score == 0:
print('密码长度必须大于等于6位')
elif score <= 2:
print('密码强度弱')
elif score <= 4:
print('密码强度较强')
elif score <= 6:
print('密码强度强')
else:
print('密码强度超强')