python - How can I select random characters in a pythonic way? -



python - How can I select random characters in a pythonic way? -

this question has reply here:

generate random letter in python 8 answers

i want generate 10 alphanumeric character long string in python . here 1 part of selecting random index list of alphanumeric chars.

my plan :

set_list = ['a','b','c' ........] # way till finish [a-za-z0-9] index = random() # utilize python's random generator some_char = setlist[index]

is there improve way of choosing character randomly ?

the usual way random.choice()

>>> import string >>> import random >>> random.choice(string.ascii_letters + string.digits) 'v'

python random

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -