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 answersi 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
Post a Comment