Mercurial > cpython-lru_cache-weakref
diff Doc/library/string.rst @ 47973:3fa44e5e4e2b legacy-trunk
Complete issue 3083: add alternate (#) formatting to bin, oct, hex in str.format().
| author | Eric Smith <eric@trueblade.com> |
|---|---|
| date | Wed, 16 Jul 2008 00:11:49 +0000 |
| parents | 38d3a50defec |
| children | f283e3b5f917 |
line wrap: on
line diff
--- a/Doc/library/string.rst Wed Jul 16 00:00:04 2008 +0000 +++ b/Doc/library/string.rst Wed Jul 16 00:11:49 2008 +0000 @@ -321,7 +321,7 @@ The general form of a *standard format specifier* is: .. productionlist:: sf - format_spec: [[`fill`]`align`][`sign`][0][`width`][.`precision`][`type`] + format_spec: [[`fill`]`align`][`sign`][#][0][`width`][.`precision`][`type`] fill: <a character other than '}'> align: "<" | ">" | "=" | "^" sign: "+" | "-" | " " @@ -375,6 +375,10 @@ | | positive numbers, and a minus sign on negative numbers. | +---------+----------------------------------------------------------+ +The ``'#'`` option is only valid for integers, and only for binary, +octal, or decimal output. If present, it specifies that the output +will be prefixed by ``'0b'``, ``'0o'``, or ``'0x'``, respectively. + *width* is a decimal integer defining the minimum field width. If not specified, then the field width will be determined by the content. @@ -395,7 +399,7 @@ +---------+----------------------------------------------------------+ | Type | Meaning | +=========+==========================================================+ - | ``'b'`` | Binary. Outputs the number in base 2. | + | ``'b'`` | Binary format. Outputs the number in base 2. | +---------+----------------------------------------------------------+ | ``'c'`` | Character. Converts the integer to the corresponding | | | unicode character before printing. |
