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

    #-*- coding:utf-8 -*-
    '''
    简短地生成随机密码,包括大小写字母、数字,可以指定密码长度
    '''
    #生成随机密码
    from random import choice
    import string
    
    #python3中为string.ascii_letters,而python2下则可以使用string.letters和string.ascii_letters
    
    def GenPassword(length=8,chars=string.ascii_letters+string.digits):
        return ''.join([choice(chars) for i in range(length)])
    
    if __name__=="__main__":
        #生成10个随机密码    
        for i in range(10):
            #密码的长度为8
            print(GenPassword(8))

  • 相关阅读:
    ssh 远程命令
    POJ 2287
    POJ 2376
    hihoCoder1488
    POJ1854
    HDU 5510
    HDU 4352
    CodeForces 55D
    HDU 1517
    CodeForces 1200F
  • 原文地址:https://www.cnblogs.com/APeng2019/p/10719316.html
Copyright © 2011-2022 走看看