String Formatting With the % Operator

The interpolation operator % is used to do simple positional formatting:

>>>
>>> name = 'Bob'
>>> 'Hello, %s' % name
"Hello, Bob"

In this lesson, you’ll learn how to use % to format strings as well as the different format specifiers you can use to generate nicely formatted output.

Comments & Discussion

Become a Member to join the conversation.