用户输入口令后请进行强度检测:等级三种:强中弱1、口令长度小于等于8位并且纯小写英文或大写英文弱2、口令长度小于等于8位并且有小写、大写英文和非英文字符中3、口令长度大于8位并且纯小写英文或大写英文中4、口令长度大于8位且小于等于16位并且有小写英文、大写英文、非英文字符中的两种中5、口令长度大于16位并且有小写英文、大写英文、非英文字符中的两种强6、口令长度大于16位并且有小写英文、大写英文、非
password = input("请输入口令:")
判断口令长度
if len(password) <= 8: # 判断是否为纯小写或大写英文 if password.islower() or password.isupper(): print("口令弱") else: print("口令中") elif len(password) > 8 and len(password) <= 16: # 判断是否有小写英文、大写英文、非英文字符中的两种 if any(c.islower() for c in password) and any(c.isupper() for c in password) and sum(not c.isalpha() for c in password) >= 2: print("口令中") else: print("口令弱") else: # 判断是否有小写英文、大写英文、非英文字符中的三种 if any(c.islower() for c in password) and any(c.isupper() for c in password) and sum(not c.isalpha() for c in password) >= 3: print("口令强") else: print("口令中"
原文地址: https://www.cveoy.top/t/topic/fHg3 著作权归作者所有。请勿转载和采集!