What's the best way to generate random strings of a specific length in Python? -
for project, need method of creating thousands of random strings while keeping collisions low. i'm looking them 12 characters long , uppercase only. suggestions?
code:
from random import choice string import ascii_uppercase print(''.join(choice(ascii_uppercase) in range(12)))
output:
5 examples:
qpupzvvhunsn efjaczebyqeb qbqjjeeoytzy eojusueajeek qwrwliwdtdbd
edit:
if need digits, use digits
constant instead of ascii_uppercase
1 string
module.
3 examples:
229945986931 867348810313 618228923380
Comments
Post a Comment