当前位置: 首页>>代码示例>>Python>>正文


Python random.randrange方法代码示例

本文整理汇总了Python中Crypto.Random.random.randrange方法的典型用法代码示例。如果您正苦于以下问题:Python random.randrange方法的具体用法?Python random.randrange怎么用?Python random.randrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypto.Random.random的用法示例。


在下文中一共展示了random.randrange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __getitem__

# 需要导入模块: from Crypto.Random import random [as 别名]
# 或者: from Crypto.Random.random import randrange [as 别名]
def __getitem__(self, item):
        if self.first_run:
            Random.atfork()
            self.first_run = False

        content = [random.randrange(0, len(self.chars)) for _ in range(self.n_chars)]

        s = ''.join([self.chars[i] for i in content])

        d = self.gen.generate(s)
        d = Image.open(d)

        label = torch.full((self.n_chars + 2, ), self.tokenizer.EOS_token, dtype=torch.long)

        ts = self.tokenizer.tokenize(s)
        label[:ts.shape[0]] = torch.tensor(ts)

        return img_trans(d), label 
开发者ID:wptoux,项目名称:attention-ocr,代码行数:20,代码来源:dataset.py

示例2: random_string

# 需要导入模块: from Crypto.Random import random [as 别名]
# 或者: from Crypto.Random.random import randrange [as 别名]
def random_string(length=-1, charset=string.ascii_letters):
    """
    Returns a random string of "length" characters.
    If no length is specified, resulting string is in between 6 and 15 characters.
    A character set can be specified, defaulting to just alpha letters.
    """

    if length == -1:
        length = random.randrange(6, 16)
    rand_string = ''.join(random.choice(charset) for _ in range(length))
    return rand_string 
开发者ID:SySS-Research,项目名称:outis,代码行数:13,代码来源:strings.py

示例3: randomString

# 需要导入模块: from Crypto.Random import random [as 别名]
# 或者: from Crypto.Random.random import randrange [as 别名]
def randomString(length = -1, charset = string.ascii_letters):
    """
    Author: HarmJ0y, borrowed from Empire
    Returns a random string of "length" characters.
    If no length is specified, resulting string is in between 6 and 15 characters.
    A character set can be specified, defaulting to just alpha letters.
    """
    if length == -1: length = random.randrange(6,16)
    random_string = ''.join(random.choice(charset) for x in range(length))
    return random_string

#------------------------------------------------------------------------ 
开发者ID:Arno0x,项目名称:WSC2,代码行数:14,代码来源:helpers.py

示例4: random_string

# 需要导入模块: from Crypto.Random import random [as 别名]
# 或者: from Crypto.Random.random import randrange [as 别名]
def random_string(length=-1, charset=string.ascii_letters):
    """
    Returns a random string of "length" characters.
    If no length is specified, resulting string is in between 6 and 15 characters.
    A character set can be specified, defaulting to just alpha letters.
    """
    if length == -1:
        length = random.randrange(6, 16)
    random_string = ''.join(random.choice(charset) for x in range(length))
    return random_string 
开发者ID:EmpireProject,项目名称:EmPyre,代码行数:12,代码来源:helpers.py


注:本文中的Crypto.Random.random.randrange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。