Categories
How to escape characters '{' and '}' in str.format()?
For example, how to get a string like: "a_{bc}"? "{}_{{} {}}".format('a', 'b', 'c') or "{}_\{{} {}\}".format('a', 'b' , 'c') doesn't work.
Answer the question
In order to leave comments, you need to log in
Add another parenthesis: "{{, }}".format() # Outputs: {, }
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question