password = input('请输入密码:')

判断密码长度是否小于8

if len(password) < 8: print('密码强度为弱') else: # 判断密码是否纯数字或纯字母 if password.isdigit() or password.isalpha(): print('密码强度为弱') else: # 判断密码是否包含数字、大小写字母 has_digit = False has_lower = False has_upper = False for char in password: if char.isdigit(): has_digit = True elif char.islower(): has_lower = True elif char.isupper(): has_upper = True if has_digit and has_lower and has_upper: print('密码强度为强') else: print('密码强度为中')

Python 密码强度检测程序

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

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