Search code examples
pythonstringf-string

python f-string how to use the {} character for a variable and as a string


data = f'"{name}": ' + "{" + tmp + "},"  

I have such a string, but I need so that I can use the string {} as for a variable or just as a string. What do I need to do for this?


Solution

  • You need double curly brackets

    >>> print(f"{{}}")
    {}