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)
评论列表
文章目录