File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1858,10 +1858,16 @@ expression support in the :mod:`re` module).
18581858 ``{} ``. Each replacement field contains either the numeric index of a
18591859 positional argument, or the name of a keyword argument. Returns a copy of
18601860 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 ::
18621864
18631865 >>> " The sum of 1 + 2 is {0} " .format(1 + 2 )
18641866 '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!'
18651871
18661872 See :ref: `formatstrings ` for a description of the various formatting options
18671873 that can be specified in format strings.
You can’t perform that action at this time.
0 commit comments