How to format a string that contains curly braces in Python

Formatting a string that contains curly braces applies str.format() to a string containing one or more replacement fields delimited by {}. A desired curly brace must be escaped with another curly brace.

Solution for How to format a string that contains curly braces in Python : You can use double curly braces to escape curly braces when formatting a string Define a string using double curly braces where single curly braces are wanted. Then use str.format() to format this str.


how-to-format-a-string-that-contains-curly-braces-in-python