dimanche 12 juillet 2015

Generate 25 psuedo-random strings

I have code that is pseudo-randomly generating strings. How can I get my code to output 25 random strings?

import random, string

special=['@','!','#','$','%','^','&','*','(',')','-','=','+','{','[','}',']',';',':','.','>','<',',','?','/',]

def id_generator(size=25, chars=string.ascii_uppercase + string.digits + random.choice(special) ):
    return ''.join(random.choice(chars) for _ in range(size))

count = 0

def create_and_save_pseudorand():
    for count in range(100):
        return id_generator()
        #print(id_generator())

create_and_save_pseudorand()




Aucun commentaire:

Enregistrer un commentaire