| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1994,10 +1994,16 @@ expression support in the :mod:`re` module). | |||
| 1994 | 1994 | ``{}``. Each replacement field contains either the numeric index of a | |
| 1995 | 1995 | positional argument, or the name of a keyword argument. Returns a copy of | |
| 1996 | 1996 | the string where each replacement field is replaced with the string value of | |
| 1997 | - the corresponding argument. | ||
| 1997 | + the corresponding argument. For example: | ||
| 1998 | + | ||
| 1999 | + .. doctest:: | ||
| 1998 | 2000 | ||
| 1999 | 2001 | >>> "The sum of 1 + 2 is {0}".format(1+2) | |
| 2000 | 2002 | 'The sum of 1 + 2 is 3' | |
| 2003 | + >>> "The sum of {a} + {b} is {answer}".format(answer=1+2, a=1, b=2) | ||
| 2004 | + 'The sum of 1 + 2 is 3' | ||
| 2005 | + >>> "{1} expects the {0} Inquisition!".format("Spanish", "Nobody") | ||
| 2006 | + 'Nobody expects the Spanish Inquisition!' | ||
| 2001 | 2007 | ||
| 2002 | 2008 | See :ref:`formatstrings` for a description of the various formatting options | |
| 2003 | 2009 | that can be specified in format strings. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments