I am facing an issue with my code .
the thing is i want to escape { in the string.format function …
Of course one way to escape it is to use {{ (2 curly braces)
Is there any other way possible to escape without using the double curly braces.
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why would there be another solution?
{{is specified as the way of escaping braces in a format string… I can’t see why the API designers would include another way.Of course, you could also provide a format parameter and then populate it with a brace:
will give “{}” as a string, for example… but I can’t see that this is a better solution.
Perhaps if you could say why you dislike the normal solution (double curly braces) we could advise you on an alternative – but there isn’t one within the format specification “language” itself, as far as I’m aware.