python详细密码错误检测器代码

[复制链接]
查看109 | 回复0 | 2024-2-29 07:59:38 | 显示全部楼层 |阅读模式

登录网站,浏览更多精彩内容

您需要 登录 才可以下载或查看,没有账号?加入我们

×

PYTHON代码
知识点:isdigit()函数isupper()函数条件判断if 等等
[mw_shl_code=python,true]while True:
    msgs = []
    psw = input("请输入密码:")
    if not any([i.isdigit() for i in psw]):
        msgs.append("需要至少一个数字")
    if not any([i.isupper() for i in psw]):
        msgs.append("需要至少一个大写字母")
    if len(psw) < 6:
        msgs.append("密码长度至少是6位数")
    if len(msgs) == 0:
        print("密码验证通过")
        break
    else:
        print("密码不通过,有如下原因")
        for note in msgs:
            print("*",note)[/mw_shl_code]
中国领先的数字技术资源交流中心!

30

主题

10

回帖

275

积分

学徒

积分
275
学费
218