Skip to content

Instantly share code, notes, and snippets.

@ipan
Created January 15, 2018 02:00
Show Gist options
  • Save ipan/fb35a6380e9be12459c77cd2aed3e880 to your computer and use it in GitHub Desktop.
Save ipan/fb35a6380e9be12459c77cd2aed3e880 to your computer and use it in GitHub Desktop.
generate random string
def rand_string(length):
""" Generates a random string of numbers, lower- and uppercase chars. """
rand_str = ''.join(random.choice(string.ascii_lowercase
+ string.ascii_uppercase
+ string.digits)
for i in range(length))
return rand_str
print(rand_string(10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment