vendredi 20 mai 2016

How to generate case insensitive string with random module

I need to generate random 32-digit number along with 15-character string to get something like 09826843-5112-8345-7619-372151470268 and qcRtAhieRabnpUaQ. I use following code to generate number:

import random

"-".join(['%08d' % random.randrange(0, 10e7), 
          '%04d' % random.randrange(0, 10e3), 
          '%04d' % random.randrange(0, 10e3), 
          '%04d' % random.randrange(0, 10e3), 
          '%012d' % random.randrange(0, 10e11)]) 

Is there a similar way to create case insensitive 15-char string with just random module?




Aucun commentaire:

Enregistrer un commentaire