当前位置:网站首页>课堂作业--密码强度判断
课堂作业--密码强度判断
2022-08-08 06:22:00 【掉发小丸子】
用户输入一个字符串做为密码,判断密码强度,规则为:密码长度小于8弱密码,密码长度大于等于8且包含至少2种字符为中等强度、密码包含3种字符为强、包含全部4种字符为极强。
提示:
string.digits 可返回’0123456789’
string.ascii_lowercase 可返回’abcdefghijklmnopqrstuvwxyz’
string.ascii_uppercase 可返回’ABCDEFGHIJKLMNOPQRSTUVWXYZ’
string.punctuation 可返回’!"#$%&’()*+,-./:;<=>[email protected][\]^_`{|}~’
import string
a=list(input(""))
digits=[]
ascii_lowercase=[]
ascii_uppercase=[]
punctuation=[]
count=0
if len(a)<8:
print("弱")
elif len(a)>=8:
for i in a:
if i in string.digits :
digits.append(i)
if i in string.ascii_lowercase :
ascii_lowercase.append(i)
if i in string.ascii_uppercase :
ascii_uppercase.append(i)
if i in string.punctuation:
punctuation.append(i)
#判断运用了哪些字符方式,并用标志count表示
if digits:
count=count+1
if ascii_lowercase:
count=count+1
if ascii_uppercase:
count=count+1
if punctuation:
count=count+1
#通过count的值可以知道运用了多少种,以此来判断强度
if count==2:
print("中")
if count==3:
print("强")
if count==4:
print("极强")
结果:
123sdf
弱
***Repl Closed***
12345678Aa!
极强
***Repl Closed***
边栏推荐
猜你喜欢
随机推荐
Redis集群
Summary of digital IC design written test questions (4): some basic knowledge points
es6模块+异步promise+async/await
结合实践总结docker 安装 mysql5.7
node模块
教你六步拆解 DDD领域驱动设计落地实践
装机~ E5 剪辑
轮播图-js
基于FTP协议的文件上传与下载
正则表达式
Educational Codeforces Round 133 (Rated for Div. 2) C Supplement
命令提示符adb shell的具体配置和使用方法
torch.gather() usage interpretation
YoloV4训练自己的数据集(六)之Yolo -Tiny
C语言中求两数最大公约数的三种方法
模板引擎art-template
C语言初阶阶段的重难点知识总结
使用pyQt 网格布局(QGridLayout)创建一个计算器
C人脸识别
List扩容机制









