Learn about the available tools for string formatting in Python, including f-strings and the .format() method. Understand how to format strings using f-strings for eager interpolation and the .format() method for lazy interpolation. Compare the features and readability of f-strings, the .format() method, and the modulo operator (%).

16m read timeFrom realpython.com
Post cover image
Table of contents
Interpolating and Formatting Strings in PythonUsing F-Strings to Format StringsUsing str.format() to Format StringsFormatting Strings With the Modulo Operator ( % )Deciding Which String Formatting Tool to UseConclusion

Sort: