diff options
author | Georg Brandl <georg@python.org> | 2016-02-22 13:52:55 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2016-02-22 13:52:55 (GMT) |
commit | f1d371bde9be7bf9dab21114b8137c66476a20ac (patch) | |
tree | 714b663ebbbf6eac404a9b09159f0305496085a3 /Doc/tutorial | |
parent | 6fe57ad229d46516c1ead1d37c015824b2428746 (diff) | |
download | cpython-f1d371bde9be7bf9dab21114b8137c66476a20ac.zip cpython-f1d371bde9be7bf9dab21114b8137c66476a20ac.tar.gz cpython-f1d371bde9be7bf9dab21114b8137c66476a20ac.tar.bz2 |
Update example; str(float) changed so there is difference now.
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/inputoutput.rst | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 5314fed..02bb28b 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -152,11 +152,11 @@ Positional and keyword arguments can be arbitrarily combined:: ``'!a'`` (apply :func:`ascii`), ``'!s'`` (apply :func:`str`) and ``'!r'`` (apply :func:`repr`) can be used to convert the value before it is formatted:: - >>> import math - >>> print('The value of PI is approximately {}.'.format(math.pi)) - The value of PI is approximately 3.14159265359. - >>> print('The value of PI is approximately {!r}.'.format(math.pi)) - The value of PI is approximately 3.141592653589793. + >>> contents = 'eels' + >>> print('My hovercraft is full of {}.'.format(contents)) + My hovercraft is full of eels. + >>> print('My hovercraft is full of {!r}.'.format(contents)) + My hovercraft is full of 'eels'. An optional ``':'`` and format specifier can follow the field name. This allows greater control over how the value is formatted. The following example |