What are the backslashes in the string?

The second example is legacy code inherited from C and written into early versions of Python, while the first was a late addition to version 2.7.x, i believe. It is far superior to the its predecessor in many ways.

This page compares the two…

https://pyformat.info/

Study the examples and in the end, ask yourself, which is more powerful and robust?

Aside

When the opening/closing quotes are single, we don’t need to escape double quotes in the string.

'The poem "{}" is written by {}.'.format(title, poet)
3 Likes