dimanche 30 octobre 2016

Copy random string 100 times on python - print to cli

I have this code, which generates a random string of 28 characters in python:

import string
import random

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

Then I call this method from command line like: id_generator()

Now to have this printed on cli, I've tried with this line, as a last one after return: print (id_generator()) but it doesnt print anything to cli, I have to execute the script inside python console with execfile

Also, how can I duplicate the random generated string 100 times?

Any ideas on this?




Aucun commentaire:

Enregistrer un commentaire