python script generates random letter + number password function
- 2020-09-16 07:36:50
- OfStack
The following is a code to introduce the python script to generate random letters + Numbers password function. The specific code is as follows:
#coding:utf-8
import random,string
def GetPassword(length):
# The number of randomly generated Numbers
Ofnum=random.randint(1,length)
Ofletter=length-Ofnum
# The selected ofnum A digital
slcNum=[random.choice(string.digits) for i in range(Ofnum)]
# The selected ofletter A letter
slcLetter=[random.choice(string.ascii_letters) for i in range(Ofletter)]
# Disrupted combination
slcChar=slcLetter+slcNum
random.shuffle(slcChar)
# Generate random password
getPwd=''.join([i for i in slcChar])
return getPwd
if __name__=='__main__':
print( GetPassword(6)) #GetPassword() Customize the random password length
conclusion
Above is the python script to you this site to generate random letters + Numbers password function, I hope to help you, if you have any questions welcome to give me a message, this site will reply you in time!