mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Update example; str(float) changed so there is difference now.
This commit is contained in:
parent
6fe57ad229
commit
f1d371bde9
1 changed files with 5 additions and 5 deletions
|
@ -152,11 +152,11 @@ Positional and keyword arguments can be arbitrarily combined::
|
||||||
``'!a'`` (apply :func:`ascii`), ``'!s'`` (apply :func:`str`) and ``'!r'``
|
``'!a'`` (apply :func:`ascii`), ``'!s'`` (apply :func:`str`) and ``'!r'``
|
||||||
(apply :func:`repr`) can be used to convert the value before it is formatted::
|
(apply :func:`repr`) can be used to convert the value before it is formatted::
|
||||||
|
|
||||||
>>> import math
|
>>> contents = 'eels'
|
||||||
>>> print('The value of PI is approximately {}.'.format(math.pi))
|
>>> print('My hovercraft is full of {}.'.format(contents))
|
||||||
The value of PI is approximately 3.14159265359.
|
My hovercraft is full of eels.
|
||||||
>>> print('The value of PI is approximately {!r}.'.format(math.pi))
|
>>> print('My hovercraft is full of {!r}.'.format(contents))
|
||||||
The value of PI is approximately 3.141592653589793.
|
My hovercraft is full of 'eels'.
|
||||||
|
|
||||||
An optional ``':'`` and format specifier can follow the field name. This allows
|
An optional ``':'`` and format specifier can follow the field name. This allows
|
||||||
greater control over how the value is formatted. The following example
|
greater control over how the value is formatted. The following example
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue