mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
remove auto-numbered format fields
This commit is contained in:
parent
ed76861682
commit
88a0b17d54
1 changed files with 3 additions and 3 deletions
|
@ -123,7 +123,7 @@ with zeros. It understands about plus and minus signs::
|
|||
|
||||
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 @@ Positional and keyword arguments can be arbitrarily combined::
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue