import re import configparser import os cf = configparser.ConfigParser() cf.read("Config.ini",encoding='utf8') pwd_Length = cf.getint("Password","pwd_Length") def checkPassword(password): passwordReg = re.compile(r'^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{'+str(pwd_Length)+',}$', re.VERBOSE) match = passwordReg.match(password) return match is not None #print("1 "+str(checkPassword('A*a1'))) # False #print("2 "+str(checkPassword('AaBbCcD111111d'))) # False #print("3 "+str(checkPassword('ABCD#1234a11'))) # False #print("4 "+str(checkPassword('abcd1234I'))) # False #print("5 "+str(checkPassword('Aa123456'))) # True
浙公网安备 33010602011771号