Created
May 12, 2021 00:01
-
-
Save kgriffs/cc977ae29505213c8a8a4ef742494d6e to your computer and use it in GitHub Desktop.
Python: Generate a random string of random length from a finite character set
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
def randstr(max_count=32, charset=(string.ascii_letters + '-')): | |
return ''.join( | |
random.choice(charset) | |
for _ in range(random.randint(1, max_count)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment