auth.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:xiaodi 作者: shenaishiren 项目源码 文件源码
def generate_invitingcode():
    random_seed = [
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
        'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z',
        'x', 'c', 'v', 'b', 'n', 'm', 'P', 'O', 'I', 'U',
        'Y', 'T', 'R', 'E', 'W', 'Q', 'A', 'S', 'D', 'F',
        'G', 'H', 'J', 'K', 'L', 'M', 'N', 'B', 'V', 'C',
        'X', 'Z'
    ]
    code = "".join(random.sample(random_seed, random.randint(4, 8)))
    while True:
        temp = yield get_db_object_by_attr(User, code=code, ignore=True)
        if not temp:
            break
        code = "".join(random.sample(random_seed, random.randint(4, 8)))

    raise gen.Return(code)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号