6.4. String-only Operators
6.4.1. Format Operator (%)
One of Python's coolest features is the string format operator. This operator is unique to strings and makes up for the pack of having functions from C's printf() family. In fact, it even uses the same symbol, the percent sign (%), and supports all the printf() formatting codes.
The syntax for using the format operator is as follows:
format_string % (arguments_to_convert)
The format_string on the left-hand side is what you would typically find as the first argument to printf(), the format string with any of the embedded % codes. The set of valid codes is given in Table6.4. The arguments_to_convert parameter matches the remaining arguments you would send to printf(), namely the set of ...
Get Core Python Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.