f-string

Applies to: python

An f-string (formatted string literal) embeds expressions directly in a string with {...}, the cleanest way to build text from values. Add a format spec after a colon for rounding, padding, etc.

x = 3.14159
f"x = {x:.2f}"      # "x = 3.14"
f"sum = {a + b}"    # inline expression

See also: data-type