Created
April 4, 2012 20:32
-
-
Save joshgachnang/2305367 to your computer and use it in GitHub Desktop.
Python Random Alphanumeric String
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 | |
# Returns a random alphanumeric string of length 'length' | |
def random_key(length): | |
key = '' | |
for i in range(length): | |
key += random.choice(string.lowercase + string.uppercase + string.digits) | |
return key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment