def generate_random_string ( chars = 7 ) : return u"" . join ( random . sample ( string . ascii_letters * 2 + string . digits , chars ) )
python random char gener
def generate_random_string(chars=7):
    """

    :param chars:
    :return:
    """
    return u"".join(random.sample(string.ascii_letters * 2 + string.digits, chars))