Python随机生成100个优惠券码

2022-05-03 00:00:00 生成 随机 优惠券

如果商家活动需要100个优惠券码,这段代码帮你随机生成100个不同的优惠券码,代码使用随机字符组合生成,可以自定义生成优惠券的数量和代码长度。

"""
皮蛋编程(https://www.pidancode.com)
创建日期:2022/4/27
功能描述:Python随机生成100个优惠券码
"""
import string
import random

KEY_LEN = 20
KEY_ALL = 100


def base_str():
    return string.ascii_letters + string.digits


def key_gen():
    keylist = [random.choice(base_str()) for i in range(KEY_LEN)]
    return "".join(keylist)


def key_num(num, result=None):
    if result is None:
        result = []
    for i in range(num):
        result.append(key_gen())
    return result


def print_key(num):
    for i in key_num(num):
        print(i)


if __name__ == "__main__":
    print_key(KEY_ALL)

输出:

DMYbdT9EFbMwjngPUshs
aq4wjKt2xbWF5Q6JdTwU
gGcZsVBOGjh1xVNgST5e
mxIuQXRXPt9WUT9EUkvT
jkR89d4vOV7y6MHA5iGL
nAuoz5Xi3geNgVB2AZe2
YtIeGNhWHNln1ZdAovDa
WR0pzAQ7HwiaEwzqr9ac
pErpE9fHpCzYQC7bA4Qs
bij3LHTyTnIj85SlQTDw
3Jzzms0tj3m2lgA0QMVe
EWjJRS3A5rThDe6y1wGS
qWyrrwXSkqo1SCMt7Vz7
FE1aBqcu4pzxviMgx7zs
0q7zSX7TrnVwDEO3Nb9x
Ncto7lFKBUK0aErZjPQR
24iEQZJ5XxH181x8VESZ
mrUkNnsrmpPqsvEqToj1
SontpSNlWutWDdhWeTra
oGIF2XSNmvgrXTq2ZQuP
ZOo7vVsfHe6OT1Dlbgub
EqUaK5D6WamRIhwfu2sD
UWZTjbirohoaU1RIjYTP
XHcwvMRkQP9UZgUqpmF8
wgyBXA7s9j2yS0gHe0L1
ItZ1sOB11SxxwZ8aTaU3
eEyE2nOlMOHR3VX0Jr4G
Ar8D0zx8MwBMAShT0Kgr
U9r7XuynU8GC1NMaY7o7
XfNI1blEJJdof6xAbldh
OxwBMigtKl89FItvcC4K
VqQNLpdv8J1IuQetsZmZ
Y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