def check_password(password): if len(password) < 8: return False has_upper = False has_lower = False has_digit = False for char in password: if char.isupper(): has_upper = True elif char.islower(): has_lower = True elif char.isdigit(): has_digit = True return has_upper and has_lower and has_digit

example usage

print(check_password('Password123')) # True print(check_password('weakpass')) # False

Python 密码验证函数:检查密码强度

原文地址: https://www.cveoy.top/t/topic/opZq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录