Merged revisions 78442 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78442 | eric.smith | 2010-02-25 09:18:57 -0500 (Thu, 25 Feb 2010) | 9 lines Merged revisions 78440 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78440 | eric.smith | 2010-02-25 09:14:35 -0500 (Thu, 25 Feb 2010) | 1 line Issue #5965: Add documentation for parts of format specification language. ........ ................
This commit is contained in:
parent
fa2936c0cc
commit
ea2e7898a1
|
@ -296,8 +296,9 @@ specification is to be interpreted.
|
||||||
Most built-in types implement the following options for format specifications,
|
Most built-in types implement the following options for format specifications,
|
||||||
although some of the formatting options are only supported by the numeric types.
|
although some of the formatting options are only supported by the numeric types.
|
||||||
|
|
||||||
A general convention is that an empty format string (``""``) produces the same
|
A general convention is that an empty format string (``""``) produces
|
||||||
result as if you had called :func:`str` on the value.
|
the same result as if you had called :func:`str` on the value. A
|
||||||
|
non-empty format string typically modifies the result.
|
||||||
|
|
||||||
The general form of a *standard format specifier* is:
|
The general form of a *standard format specifier* is:
|
||||||
|
|
||||||
|
@ -308,7 +309,7 @@ The general form of a *standard format specifier* is:
|
||||||
sign: "+" | "-" | " "
|
sign: "+" | "-" | " "
|
||||||
width: `integer`
|
width: `integer`
|
||||||
precision: `integer`
|
precision: `integer`
|
||||||
type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "x" | "X" | "%"
|
type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
|
||||||
|
|
||||||
The *fill* character can be any character other than '}' (which signifies the
|
The *fill* character can be any character other than '}' (which signifies the
|
||||||
end of the field). The presence of a fill character is signaled by the *next*
|
end of the field). The presence of a fill character is signaled by the *next*
|
||||||
|
@ -380,6 +381,17 @@ used from the field content. The *precision* is not allowed for integer values.
|
||||||
|
|
||||||
Finally, the *type* determines how the data should be presented.
|
Finally, the *type* determines how the data should be presented.
|
||||||
|
|
||||||
|
The available string presentation types are:
|
||||||
|
|
||||||
|
+---------+----------------------------------------------------------+
|
||||||
|
| Type | Meaning |
|
||||||
|
+=========+==========================================================+
|
||||||
|
| ``'s'`` | String format. This is the default type for strings and |
|
||||||
|
| | may be omitted. |
|
||||||
|
+---------+----------------------------------------------------------+
|
||||||
|
| None | The same as ``'s'``. |
|
||||||
|
+---------+----------------------------------------------------------+
|
||||||
|
|
||||||
The available integer presentation types are:
|
The available integer presentation types are:
|
||||||
|
|
||||||
+---------+----------------------------------------------------------+
|
+---------+----------------------------------------------------------+
|
||||||
|
@ -407,6 +419,11 @@ The available integer presentation types are:
|
||||||
| None | The same as ``'d'``. |
|
| None | The same as ``'d'``. |
|
||||||
+---------+----------------------------------------------------------+
|
+---------+----------------------------------------------------------+
|
||||||
|
|
||||||
|
In addition to the above presentation types, integers can be formatted
|
||||||
|
with the floating point presentation types listed below (except
|
||||||
|
``'n'`` and None). When doing so, :func:`float` is used to convert the
|
||||||
|
integer to a floating point number before formatting.
|
||||||
|
|
||||||
The available presentation types for floating point and decimal values are:
|
The available presentation types for floating point and decimal values are:
|
||||||
|
|
||||||
+---------+----------------------------------------------------------+
|
+---------+----------------------------------------------------------+
|
||||||
|
|
Loading…
Reference in New Issue