<div class="gmail_quote">On 25 December 2011 17:32, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com">storchaka@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
25.12.11 15:48, Steven D'Aprano написав(ла):<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sun, 25 Dec 2011 08:30:46 -0500, Roy Smith wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I want to create a string of 20 random digits (I'm OK with leading<br>
zeros). The best I came up with is:<br>
''.join(str(random.randint(0, 9)) for i in range(20))<br>
Is there something better?<br>
</blockquote>
'%20d' % random.randint(0, 10**20-1)<br>
</blockquote>
<br></div>
'%020d' % random.randrange(10**20)</blockquote><div><br></div><div>Do the docs not advise .format now?</div><div><br></div><div>"{:20}".format(random.randrange(10**20)) </div></div>