fantasy/random.py
def random_str(length=16, only_digits=False):
    """
    生成随机字符串
    :return:
    """

    choices = string.digits
    if not only_digits:
        choices += string.ascii_uppercase

    return ''.join(random.SystemRandom().choice(choices)
                   for _ in range(length))
def random_str(length=16, only_digits=False):
    """
    生成随机字符串
    :return:
    """

    choices = string.digits
    if not only_digits:
        choices += string.ascii_uppercase

    return ''.join(random.SystemRandom().choice(choices)
                   for _ in range(length))
def random_str ( length = 16 , only_digits = False ) : choices = string . digits if not only_digits : choices += string . ascii_uppercase return '' . join ( random . SystemRandom ( ) . choice ( choices ) for _ in range ( length ) )
生成随机字符串
    :return:
生成随机字符串 : return :