As an independent developer of the Apple Store App, you need to engage in limited-time promotions, generate an activation code (or coupon) for your app, and use Python to generate 200 activation codes (or coupons)
Import String,random
Poolofchars = string.ascii_letters + string.digits
#ascii_letters是生成所有字母, from A-Z and a-z,digits are generated for all numbers 0-9.
Random_codes = lambda x, y: '. Join ([Random.choice (x) for I in range (y)])
For I in range (200):
Print (Random_codes (Poolofchars, 15))
random
A function in the library randint(inf, sup)
can produce a random integer within the specified range;
choice(sequence)
You can list
tuple
string
select an element randomly in an ordered type (such as, or).
Ascii_letters is to generate all the letters, from A-Z and a-z,digits is to generate all the numbers 0-9.
The activation code is a random combination of numbers and letters, each time from String.ascii_letters + string.digits is the total number and letter combination, that randomly selected one, in the string join link, link to specify the number of digits on the line
Lambda is a knowledge point and also has learning on Liaoche's website. Lambda is an anonymous function that can make your code more concise.
Refer to: http://blog.csdn.net/yezonggang/article/details/50978114
Learn about string reference https://www.cnblogs.com/rollenholt/archive/2011/11/25/2263722.html
Python second question Learn how to use random