Skip to content
Open

#0001 #401

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Create huqwPython
  • Loading branch information
huqw1999 authored Aug 25, 2021
commit 7d05f61c82d9f16eba926e3d398b4c150215cd59
28 changes: 28 additions & 0 deletions huqwPython
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?

import random


class GenerateCDK:

def __init__(self, Bit, Num):
self.Bit = Bit
self.Num = Num
self.CDK = None
with open('CDKs.tx', 'w') as file: # 清空txt文档 #
file.close()

def Generate(self):
for i in range(self.Num):
num_dic = [chr(i) for i in range(48, 58)]
letter_dic = [chr(i) for i in range(65, 91)]
tot_dic = num_dic + letter_dic
self.CDK = ''.join(random.sample(tot_dic, self.Bit))
with open('CDKs.tx', 'a') as file:
file.write(str(i + 1) + ' :' + str(self.CDK) + '\n')
file.close()


bit = 15
num = 200
GenerateCDK(bit, num).Generate()