Skip to content

Commit a59431d

Browse files
committed
add 0001
1 parent b998901 commit a59431d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Jaccorot/0001/0001.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/local/bin/python
2+
#coding=utf-8
3+
4+
#第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),
5+
#使用 Python 如何生成 200 个激活码(或者优惠券)?
6+
7+
import uuid
8+
9+
10+
def create_code(num, length):
11+
#生成”num“个激活码,每个激活码含有”length“位
12+
result = []
13+
while True:
14+
uuid_id = uuid.uuid1()
15+
temp = str(uuid_id).replace('-', '')[:length]
16+
if not temp in result:
17+
result.append(temp)
18+
if len(result) == num:
19+
break
20+
return result
21+
22+
print create_code(200, 20)

0 commit comments

Comments
 (0)