File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed
Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change 11# -*- coding:utf-8 -*-
22#第 0001 题:**做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用**生成激活码**(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)
3- #by DockerFan random.choice
4- import random , string
5-
63
4+ import random , string
75
8- def random_series (count ,len = 10 ):
9- str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
10- series_set = []
6+ forSelect = string .ascii_letters + "0123456789"
117
12- for i in range (0 ,count ):
13- series = ''
14- for j in range (0 ,len ):
15- series += random .choice (str )
16- if series not in series_set :
17- series_set .append (series )
18- print (series )
8+ def generate (count , length ):
9+ # count = 200
10+ # length = 20
1911
20- random_series (20 )
21-
12+ for x in range (count ):
13+ Re = ""
14+ for y in range (length ):
15+ Re += random .choice (forSelect )
16+ print (Re )
2217
18+ if __name__ == "__main__" :
19+ generate (200 , 20 )
You can’t perform that action at this time.
0 commit comments