Last active
October 8, 2020 06:26
-
-
Save xbalaji/8447f043367c3361a1f89c4789edc14e to your computer and use it in GitHub Desktop.
python_random_strings.sh
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
# generate string list | |
python3 -c 'import random,json,string; print([ "".join([random.choice(string.ascii_letters) for ix in range(15)]) for jx in range(10)])' | |
# print one each line, logic is to create a list first and use print with * and separator | |
python3 -c 'import random,string; sx = ["".join([random.choice(string.ascii_letters) for ix in range(15)]) for jx in range(10)]; print(*sx, sep="\n")' | |
# generate a csv file, the one below generates a csv file with random people name and age, change the tuple to more than 2, you could create address | |
python3 -c 'import random,string; ppl = [("".join(random.choice(string.ascii_letters) for ix in range(6)), random.randrange(20,90)) for jx in range(10)]; [print(f"{name}, {age}") for name, age in ppl]' | |
# generate AWS account numbers, random 12 digit number, primarily used for testing | |
python3 -c 'import random; acc = ["".join([str(random.randrange(10)) for ix in range(12)]) for jx in range(10)]; print(*acc, sep="\n")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment