输入一个密码,输出其强度。 如果输入密码长度小于6,则输出:len<6 当密码长度大于等于6时,包含字符种类多少表示强调多少,比如4类字符:数字、小写字母、大写字母、特殊字符(本题假设特殊字符指,.!;?<>)。 字符种类多少对应密

动态 未结 0 90
小小草
小小草 LV1 2023年9月23日 23:40 发表
password = input() # 判断密码长度 if len(password) < 6: print('len<6') else: # 定义4个变量,分别表示数字、小写字母、大写字母、特殊字符是否出现过 has_digit = False has_lower = False has_upper = False has_special = False # 遍历密码中的每个字符 for char in password: if char.isdigit(): has_digit = True elif char.islower(): has_lower = True elif char.isupper(): has_upper = True elif char in ',.!;?<>': has_special = True # 计算密码强度 count = has_digit + has_lower + has_upper + has_special if count == 1: print('weak') elif count == 2: print('below middle') elif count == 3: print('above middle') else: print('strong')
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复