''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N))
N = Anzahl der Stellen
z.B. Uppercase + Digits mit 16 Stellen:
OMD[dev1]:~$ python Python 2.7.13 (default, Jul 24 2017, 12:14:45) [GCC 6.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import string >>> import random >>> ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(16)) 'J8J3D3UMASJ33B1M'
Quelle/Mehr: https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python