Python: Random string generation with digits and upper-case letters
Here’s a nice one liner for generating a random string using just digits and upper-case letters:
''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(N))
The use of random.SystemRandom
is to make the randomness more cryptographically secure.
Via SO.
Leave a comment