在北京做网站制作一个月多少钱微信朋友圈营销方案
需求:当我使用自动化密码更改工具去更改服务器密码的时候,随机产生的密码字符串不一定符合我的密码规则,会导致更改失败。如规则为:至少包含3个数字,3个小写字母,1个大写字母,长度不小于8位。实现代码如下
def get_passwd(length=20):passwds = []while True:passwd = set(random.sample(string.ascii_letters + string.digits, length))if len(passwd.intersection(string.ascii_uppercase)) >= 1 and len(passwd.intersection(string.ascii_lowercase)) >= 3 and len(passwd.intersection(string.digits)) >= 3:passwds.append(''.join(passwd))breakreturn passwds[0]
转载于:https://blog.51cto.com/270142877/2301357