Python show-me-the-code No. 0001 generate activation Code

Source: Internet
Author: User

question No. 0001: as an independent developer of the Apple Store App, do you want to make a limited-time promotion, generate an Activation code (or coupon) for your app, and use Python to generate 200 activation codes (or coupons)?

Do not know what method to generate the activation code is more reliable, so the letter and the number of the random combination. If there is a better way please tell me:)

The generated is probably the same:

0001. Generate the Activation code. PY

#!/usr/bin/env python#coding: Utf-8ImportString, random#激活码中的字符和数字field = String.letters + string.digits#获得四个字母和数字的随机组合 def getrandom():    return "". Join (Random.sample (field,4))#生成的每个激活码中有几组 def concatenate(group):    return "-". Join ([Getrandom () forIinchRange (group)])#生成n组激活码 def generate(n):    return[Concatenate (4) forIinchRange (n)]if__name__ = =' __main__ ':PrintGenerate $)

Python show-me-the-code No. 0001 generate activation Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.