Target)( )[^=] [+ ] 0 width precision type
[Pages:2]Python 2.7 Format String Reference Guide
[...] indicate possible characters
(...) indicates an optional subexpression
{(target)(![rsa])(:((?)[^=])([+-- ])(#)(0)(width)(,)(.precision)(type))}
call repr(), str(), or ascii() prior to formatting
0-padding!
comma thousands separator
fill character
alignment: left, right, center, or padded after the sign but before digits
sign: always, negative only, or negative only but with a space for positive numbers
include base prefix (non-decimal integers only)
target
A reference to an argument, or an attribute or indexed element of an argument. The argument may be specified by name (if a keyword argument) or index. By default, arguments are displayed in order.
width
The field width (by default, determined by content).
precision
For float values, the number of digits to display after the decimal point--unless the presentation type is g or G, in which case it is the number of significant figures to display before and after the decimal point. For string values, the maximum number of characters from the input to display (longer strings will be truncated).
type
Determines the presentation of the value (see table below).
Value Type string
integer
integer or float
Presentation Types
string (default)
decimal (default) number with localized separator characters character binary octal hex, HEX
(default is to emulate str(), with default precision of 12 for floats but not displaying trailing 0s after the decimal point) fixed point: numeric (always with a digit before the decimal point) or nan or inf Fixed point: numeric or NAN or INF exponent, Exponent: scientific notation with e or E, respectively (exponent will have a sign and at least two digits) general, General: Chooses integer, fixed-point, or scientific notation based on the magnitude and precision (default: 6). The decimal point, if present, will be preceded by 0 if not another digit; no trailing 0s will be displayed after the decimal point. number: general format, but with localized separator characters %: percentage (fixed point value*100, with percent sign)
string examples ( marks the end of the output):
Value
{}
{:2}
{:5}
u'th\u0259'
th
th
th
--1
--1
--1
--1
3.14159
3.14159
float('inf') inf
inf
inf
False
False
0
0
('a', 9)
('a', 9)
None
None
None
None
see reverse for numeric examples
{:>5} th --1
{:_5.2f} --1.00 0.00 0.00 0.67
314%
3
3.14
3.14
99999900% 999999 999999.00 999999.00
inf%
inf
inf
inf
Based on Nathan Schneider ? nathan.cl ? 17 June 2012
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- programming and frameworks for ml python for data analyis
- pandas format numbers with commas
- python f string format thousand separator
- dsc 201 data analysis visualization
- implementations typically
- python 2 vs
- python string format float thousand separator
- input processing and output
- target 0 width precision type
- python course rutgers university
Related searches
- 10 0 0 0 1 gateway
- 10 0 0 0 1 admin
- item dimensions length width height
- how to read height width and length
- what is length width and height
- width height and length
- is it height length width order
- grammar measurement width height depth
- standard measurements width depth height
- height width depth
- reading measurements length width height
- length and width measurement