Skip to content

Instantly share code, notes, and snippets.

@dpineiden
Created July 26, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpineiden/2fded9ea1f9e5e8ed928371e7be631d3 to your computer and use it in GitHub Desktop.
Save dpineiden/2fded9ea1f9e5e8ed928371e7be631d3 to your computer and use it in GitHub Desktop.
Random String generator
import uuid
import shlex
import simplejson as json
import datetime
import random
def random_char():
"""
Alphabetic uppercase and number 0 to 9 on a random
selection
"""
nums = list(range(48,58))
alfab = list(range(65,91))
chars = nums + alfab
char_num = random.choice(chars)
return chr(char_num)
def my_random_string(string_length=10):
"""Returns a random string of length string_length.
:param string_length: a positive int value to define the random length
:return:
"""
a = 3
assert string_length >= a, "No es un valor positivo sobre " + str(a)
rand_list = [random_char() for i in range(string_length)]
random = "".join(rand_list)
return random
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment