I don’t think it is possible to use alternative delimiters. You need to use double-curly braces {{
}}
for curly braces that you don’t want to be replaced by format()
:
inp = """
DATABASE = {{
'name': '{DB_NAME}'
}}"""
dictionary = {'DB_NAME': 'abc'}
output = inp.format(**dictionary)
print(output)
Output
DATABASE = {
'name': 'abc'
}