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)
  • 相关阅读:
    solr 的全量更新与增量更新
    solr 服务器的搭建
    Mysql 问题
    App 微信支付
    App 支付宝支付
    Linux 常见命令
    [备注] 钉钉使用教程
    PARAMETER和ARGUMENT的区别
    无界面浏览器
    URLs ...
  • 原文地址:https://www.cnblogs.com/Dorami/p/11039637.html
Copyright © 2011-2022 走看看