We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7ded1a commit 609d1fdCopy full SHA for 609d1fd
1 file changed
pylyria/0001/0001_1.py
@@ -0,0 +1,17 @@
1
+# -*- coding: utf-8 -*-
2
+#!/usr/bin/env python
3
+#第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?
4
+import random
5
+import string
6
+
7
+def activation_code(chars = string.ascii_uppercase + string.digits, length=16):
8
+ return ''.join([random.choice(chars) for i in range(length)])
9
10
+if __name__ == '__main__':
11
+ code_collection = set()
12
+ for i in range(200):
13
+ code = activation_code()
14
+ if code not in code_collection:
15
+ code_collection.add(code)
16
+ else:
17
+ continue
0 commit comments