In Python, you can escape the opening curly brace ‘{‘ in a formatted string by using double curly braces ‘{{‘ to represent a single curly brace. Here’s an example:
something = "Hello"
formatted_string = f"{{{{ {something} }}}}"
print(formatted_string)
Output:
{{ Hello }}
In the above example, {{
represents the escaped opening curly brace, {something}
is the placeholder for the variable, and }}
represents the closing curly brace.
By doubling the curly braces, Python will interpret it as a literal curly brace and not as a placeholder.