Information formatting
In this section, we are going to learn about string formatting. We are going to learn how to format information in two ways: one by using the string format() method and the other by using the % operator.
First, we will learn string formatting using the string format() method. This method of the string class allows us to do value formatting. It also allows us to do variable substitutions. This will concatenate the elements through positional arguments.
Now, we are going to learn how to do this formatting using formatters. The string on which this method is called can contain literal text or replacement fields delimited by braces {}. Multiple pairs of {} can be used while formatting a string. This replacement field contains ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access