Python String Formatting
I need some help with the Python's new string formatter. Basically, I want the outer curly braces to not escape the string replacement field. This works: foo = 'bar' print '{%s}' %
Solution 1:
It looks like you want:
>>>foo = 'bar'>>>print('{{{0}}}'.format(foo))
'{bar}'
The outer pair of doubled {{
and }}
are copied literally to the output, leaving {0}
to be interpreted as a substitution.
Post a Comment for "Python String Formatting"