cheetah

Python: format string with custom delimiters [duplicate]

a 夏天 提交于 2019-11-26 14:53:00
问题 This question already has answers here : How can I print literal curly-brace characters in python string and also use .format on it? (12 answers) Closed last year . EDITED I have to format a string with values from a dictionary but the string already contains curly brackets. E.g.: raw_string = """ DATABASE = { 'name': '{DB_NAME}' } """ But, of course, raw_string.format(my_dictionary) results in KeyErro. Is there a way to use different symbols to use with .format() ? This is not a duplicate of