[Tutor] A file containing a string of 1 billion random digits.

ALAN GAULD alan.gauld at btinternet.com
Mon Jul 19 18:58:20 CEST 2010


Heres what I did:
Search Google for "Python format strings" and from the first link click 
on String Formatting operations in the contents pane:

http://docs.python.org/library/stdtypes.html#string-formatting-operations

Read item number 4.

:-)

 
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/




----- Original Message ----
> From: Richard D. Moores <rdmoores at gmail.com>
> To: ALAN GAULD <alan.gauld at btinternet.com>
> Cc: tutor at python.org
> Sent: Monday, 19 July, 2010 15:48:13
> Subject: Re: [Tutor] A file containing a string of 1 billion random digits.
> 
> On Mon, Jul 19, 2010 at 07:14, ALAN GAULD <
> ymailto="mailto:alan.gauld at btinternet.com" 
> href="mailto:alan.gauld at btinternet.com">alan.gauld at btinternet.com> 
> wrote:
>
>
>> 4 and executed many times. Seems the 0 in 
> 0dddd is
>> there when a dddd is a 3-digit number such as 
> 123.
>> In that case a zero is prefixed to 123 to produce
>> 
> 0123. Or if just 23, 2 zeros are prefixed, etc.
>> 
> Correct?
>
> Yes, the zero indicates that the string should be 
> padded
> with zeros to the length specified. The format string
> 
> documentation gives all the details

I've been unable to find any mention 
> of that use of the asterisk in
the 3.1 docs, in


> href="http://docs.python.org/py3k/library/string.html#formatspec" target=_blank 
> >http://docs.python.org/py3k/library/string.html#formatspec

or


> href="http://docs.python.org/py3k/library/string.html#formatstrings" 
> target=_blank 
> >http://docs.python.org/py3k/library/string.html#formatstrings

Suggestion?

Dick


More information about the Tutor mailing list