by @codeexamples

How to print literal curly-brace characters in python string and use .format

Home » python » How to print literal curly-brace characters in python string and use .format

You need to wrap it with double curly braces {{ }} to print literal curl-brace characters in a python string.

Here is an example:

name = " {{ Hello python }} {0}"

print (name.format(101))

Output:

{ Hello python } 101

Another example:

name = " {{ Hello python }} {0} {1}"

print (name.format(101,109))

Output:

{ Hello python } 101 109