Module f (formatted string literals)
Format strings contain “replacement fields” surrounded by curly braces
{}. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output. If you need to include a brace character in the literal text, it can be escaped by doubling:
{{and
}}.
Example:
f:‘{2+2:3}’gives
‘ 4’
.replacement_field ::= "{" f_expression [":" format_spec] "}" format_spec ::= ["<"](width["."precision] | "."[precision]) width ::= digit+ precision ::= digit+
In 11l all fields by default are right-aligned regardless of their type {…}.
<forces the field to be left-aligned.
Preceding the width field by a zero (
0) character enables zero-padding (e.g.,
f:‘{2+2:03}’gives
‘004’
).There are no types (like
dor
fin Python).
Also note how paired quotes are come in handy:
print(f:‘Id: {row[‘id’]}’)