How to avoid char in Python 3 '' 'string?

Here is the line:

'''This is a test { <-- escape these ---> } ''' 

I would like to avoid

{

and

}

in format, how can I do this? Thank you

+6
source share
1 answer

String syntax format :

If you need to include a bracket character in a literal text, you can avoid it by doubling it: {{and}}.

Try the following:

 '''This is a test {{ <-- escape these ---> }} and the value is {0}'''.format(42) 
+8
source

Source: https://habr.com/ru/post/902734/


All Articles