Created
December 2, 2021 20:23
-
-
Save angrychimp/d2765a00986b066e86be296b9d3725f3 to your computer and use it in GitHub Desktop.
Generates random coupon codes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
from sys import argv | |
from time import time | |
from datetime import datetime, timedelta | |
# print("\n".join([",".join([x, "".join(random.choices(string.ascii_lowercase + string.digits, k=10))]) for x in range(10)])) | |
start = int(time()) | |
print(",".join(["id","code","expdate"])) | |
print("\n".join([",".join([ | |
str(x+start), | |
"".join(random.choices(string.ascii_lowercase + string.digits, k=10)), | |
(datetime.now() + timedelta(days=(15+random.randint(0,15)))).strftime('%Y-%m-%d') if random.randint(0,9) > 2 else "1970-01-01" | |
]) for x in range(int(argv[1]))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment