| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1858,10 +1858,16 @@ expression support in the :mod:`re` module). | |||
| 1858 | 1858 | ``{}``. Each replacement field contains either the numeric index of a | |
| 1859 | 1859 | positional argument, or the name of a keyword argument. Returns a copy of | |
| 1860 | 1860 | the string where each replacement field is replaced with the string value of | |
| 1861 | - the corresponding argument. | ||
| 1861 | + the corresponding argument. For example: | ||
| 1862 | + | ||
| 1863 | + .. doctest:: | ||
| 1862 | 1864 | ||
| 1863 | 1865 | >>> "The sum of 1 + 2 is {0}".format(1+2) | |
| 1864 | 1866 | 'The sum of 1 + 2 is 3' | |
| 1867 | + >>> "The sum of {a} + {b} is {answer}".format(answer=1+2, a=1, b=2) | ||
| 1868 | + 'The sum of 1 + 2 is 3' | ||
| 1869 | + >>> "{1} expects the {0} Inquisition!".format("Spanish", "Nobody") | ||
| 1870 | + 'Nobody expects the Spanish Inquisition!' | ||
| 1865 | 1871 | ||
| 1866 | 1872 | See :ref:`formatstrings` for a description of the various formatting options | |
| 1867 | 1873 | that can be specified in format strings. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments