Python generates random cipher strings
The random module of Python can generate stochastic numbers, mostly using this to generate random passwords.
string module: string.letters,string.printable,string.printable
>>> import string>>> string.letters ' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz ' > >> string.digits ' 0123456789 ' >>> string.printable ' 0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz! " #$%&\ ' () *+,-./:;<=>[email protected][\\]^_ ' {|} ~ \t\n\r\x0b\x0c '
Here's a random number generation method that randomly generates 10 groups of numbers, uppercase and lowercase letters, and you can specify the length of the random number:
#!/usr/bin/env python #-*- coding:utf-8 -*-" Generate random passwords briefly, including uppercase and lowercase letters, numbers, and can specify password length # generate random password ' ' in Import randomimport string#python3 for String.ascii_letters, The python2 can be used with string.letters and String.ascii_lettersdef genpassword (length): chars= string.ascii_letters+string.digits return '. Join ([Random.choice (chars) for i in range (length)]) " #得出的结果中字符会有重复的 #return ". Join (Random.sample (chars, 15)) #得出的结果中字符不会有重复的 ' ' if __name__== ' __main__ ': ' #生成10个随机密码 ' for i in range (: #密码的长度为15 print genpassword ()
Python passwd.py Bdmxufzf5ktyhjjedqijymjob7or2tpbkk58ptwqiwf9zpufypnwbmx9msyw9rna9d8oxebjs7sdh2fefkhqouxj9fwzrnrc0k94yn8ksmshewb2lezxeavir Bqf7c6vjprln6z99a3zyw37cb7bej
This article from "~" blog, declined reprint!
Python generates random passwords