get random 8 string python code example
Example 1: python random string
import secrets
secrets.token_hex(nbytes=16)
# this will produce something like
# aa82d48e5bff564f3221d02194611c13
Example 2: random string generate python of 2.7
>>> import string
>>> import random
>>> def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))