Random string of digits?

Roy Smith roy at panix.com
Sun Dec 25 08:30:46 EST 2011


I want to create a string of 20 random digits (I'm OK with leading 
zeros).  The best I came up with is:

''.join(str(random.randint(0, 9)) for i in range(20))

Is there something better?



More information about the Python-list mailing list