Mercurial > cpython-lru_cache-weakref
diff Doc/tutorial/inputoutput.rst @ 58167:3eceef378065 2.6
remove auto-numbered format fields
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Wed, 06 Jan 2010 00:55:21 +0000 |
| parents | 85aa706f7126 |
| children | b36cb4602e21 |
line wrap: on
line diff
--- a/Doc/tutorial/inputoutput.rst Mon Jan 04 21:51:09 2010 +0000 +++ b/Doc/tutorial/inputoutput.rst Wed Jan 06 00:55:21 2010 +0000 @@ -123,7 +123,7 @@ Basic usage of the :meth:`str.format` method looks like this:: - >>> print 'We are the {} who say "{}!"'.format('knights', 'Ni') + >>> print 'We are the {0} who say "{1}!"'.format('knights', 'Ni') We are the knights who say "Ni!" The brackets and characters within them (called format fields) are replaced with @@ -153,9 +153,9 @@ convert the value before it is formatted. :: >>> import math - >>> print 'The value of PI is approximately {}.'.format(math.pi) + >>> print 'The value of PI is approximately {0}.'.format(math.pi) The value of PI is approximately 3.14159265359. - >>> print 'The value of PI is approximately {!r}.'.format(math.pi) + >>> print 'The value of PI is approximately {0!r}.'.format(math.pi) The value of PI is approximately 3.141592653589793. An optional ``':'`` and format specifier can follow the field name. This allows
