Skip to content

Commit 45a3f02

Browse files
author
StevenWang
committed
wangzhou 0001 answer
1 parent 98e9496 commit 45a3f02

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

WangZhou/0001/gen_act_key.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import uuid
2+
3+
4+
def gen_act_key(n):
5+
"""
6+
生成 n 个激活码,保存在字典。
7+
:param n: int
8+
:return: dict
9+
"""
10+
act_code_store = {}
11+
12+
for i in range(n):
13+
code0 = str(uuid.uuid1()).split('-')[0]
14+
code1 = '-'.join(str(uuid.uuid3(uuid.NAMESPACE_DNS, f'{i}')).split('-')[1:])
15+
act_code = code0 + '-' + code1
16+
act_code_store[f'id-{i}'] = act_code
17+
return act_code_store
18+
19+
20+
if __name__ == "__main__":
21+
activity_code = gen_act_key(200)

0 commit comments

Comments
 (0)