Functional
Beginner 2 min read
f-String Formatting Tricks
Go beyond basic interpolation with powerful format specs
Python Academy
Python Engineer
f-strings (formatted string literals, introduced in Python 3.6) embed expressions directly in string literals using `{expr:format_spec}`. The format spec follows the same mini-language as `format()`: width, alignment (`<`, `>`, `^`), fill character, numeric grouping (`,`), and precision. The `=` specifier added in 3.8 prints both the expression text and its value, making it ideal for quick debugging.
#python
#fstring
#formatting
#strings