第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?
https://github.com/Yixiaohan/show-me-the-code
import random codeLength = 12 codeCount = 200 codeOrig = "ABCDEFGHIJKLMNOPQRST1234567890" def makePromoteCode(count): for i in range(count): promotecode = "" for x in xrange(codeLength): promotecode += random.choice(codeOrig) print promotecode if __name__ == '__main__': makePromoteCode(codeCount)