Skip to content

Glossary: Python Beyond the Basics

f-string format specifiers

Also written: :.2f, :<12, :>8, 05d, .0%, format code

Codes after a colon inside an f-string's braces that control layout: `:.2f` gives two decimal places, `:<12` and `:>8` pad left or right, `05d` pads with zeros, and `.0%` shows a percentage.

Where the book teaches it

Related terms

f-string debug specifier (=)!r