zoukankan      html  css  js  c++  java
  • 随机生成密码

    #1、必须包含大小写字母、数字、特殊字符,密码不能以特殊字符开头,长度在8-15


    #1、先产生一个随机的长度,8
    #2、先从所有的大写字母里面取2位,再从所有的小写字母取2位,再从数字里面取2,再从特殊字符串里面取2个

    #1、先产生一个随机的长度,8,然后从大小写字母、数字、特殊字符,取几位
    #2、分别和


    import random
    import string

    def create_password(num):
    passwords = set()
    while len(passwords) != num:
    length = random.randint(8,15)
    password1 = random.sample(string.ascii_letters+string.digits+string.punctuation,length)
    if set(password1) & set(string.ascii_uppercase) and set(password1) & set(string.ascii_lowercase) and
    set(password1) & set(string.digits) and set(password1) & set(string.punctuation) and password1[0] not in string.punctuation:
    password = ''.join(password1) +' '
    passwords.add(password)
    with open('passwords.txt','w') as fw:
    fw.writelines(passwords)
  • 相关阅读:
    【深入理解jvm笔记】Java发展史以及jdk各个版本的功能
    老罗Android视频教程(第一版)
    微软平台开发
    asp.net mvc 小结
    JavaScript代码段
    CSS代码片段
    c#代码片段
    Windows Phone 链接
    HttpRequest
    Win32
  • 原文地址:https://www.cnblogs.com/Dorami/p/11039637.html
Copyright © 2011-2022 走看看