Back to search

String formatting and f-strings

Python supports old `%` formatting, `str.format`, and f-strings, with f-strings usually being the clearest modern default.

Python Easy Theory

String formatting and f-strings

Python supports old `%` formatting, `str.format`, and f-strings, with f-strings usually being the clearest modern default.

  • f-strings embed expressions directly
  • format works well for reusable templates
  • % formatting still appears in older code

String formatting and f-strings