zoukankan      html  css  js  c++  java
  • 用python实现密码校验程序

    密码需要符合下面的要求:

    8个字符以上,包含数字,大小写,开头不能为特殊字符。

    #! /usr/bin/python
    import re

    password = str(input())

    def lenOK(pwd):
        if(len(pwd)>=8):
            return True
        else:
            print("WARNING: The password should be at least 8 characters.")
            return False

    def numberOK(pwd):
        pattern = re.compile('[0-9]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should include at least 1 number.")
            return False

    def upperOK(pwd):
        pattern = re.compile('[A-Z]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should include at least 1 upper character.")
            return False

    def lowerOK(pwd):
        pattern = re.compile('[a-z]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should include at least 1 lower character.")
            return False

    def symbolOK(pwd):
        pattern = re.compile('^[a-z0-9A-Z]+')
        match = pattern.findall(pwd)
        if match:
            return True
        else:
            print("WARNING: The password should start with numbers or characters.")
            return False

    def checkpwd(pwd):
        check = lenOK(pwd) and numberOK(pwd) and upperOK(pwd) and lowerOK(pwd) and symbolOK(pwd)
        if (check):
            print("The password is legal.")
        else:
            print(check)

    checkpwd(password)

  • 相关阅读:
    批处理压缩iis日志
    centos6 安装wkhtmltopdf 生成pdf
    SpringMVC
    MVC的了解
    Eclipse创建SpringMVC,Spring, Hibernate项目
    mysql表基本查询
    JVM垃圾回收机制与内存回收
    mysql外键(Foreign Key)的使用
    MyEclipse做的项目改成eclipse能用的
    invalid location of tag 解决办法
  • 原文地址:https://www.cnblogs.com/guolongnv/p/8081471.html
Copyright © 2011-2022 走看看