"{" [field_name] ["!" conversion] [":" format_spec] "}"
/ "r"|"s" \
/ (r)epr (s)tr \
arg_name \
| ("." attribute_name | "[" element_index "]")* \
| | | \
| identifier integer | index_string |
| (quotes |
[identifier not required) |
|integer] |
|
_________________________________________________________/ \________
/ \
":"
[[fill]align][sign][#][0][width][,][.precision][type]
[default]--> < left + | | (int) (int) b base 2
[default --> > right [-] | | c character
for ^ center " " | \ d base 10
numbers] = | `zero padding e exponent (e)
| E exponent (E)
use 0b,0o,0x f fixed point
for 2 8 16 F ^^(same)^^
b base 2 c character [default]--> g general (???)
o base 8 s string G general 2 (?)
d base 10 n number (general 3)
x base 16 o base 8
X base 16 s string
e, E exponent (lower case) x base 16
f, F, % fixed point (upper case) X base 16
g, G, n (general numbers) (x100, f) % percentage
print("{:>6.5}".format(var))# right aligned to 6 digits, precision 5 (5 numbers including point e.g. 0.123)print("{:08}".format(var))# filled up with 0 to 8 digits, 00001234print("0x{:0x}".format(int(var)))# in hex small case, 0x4d2print("0x{:0X}".format(int(var)))# in hex small case, 0x4D2print("{:04x}".format(int(var)))# in hex small case, 0x04d2print("{:04X}".format(int(var)))# in hex small case, 0x04D2