'How to have curly brace inside f string [duplicate]
I am trying the below in python with f string
test=f"""
{
"""
print(test)
It gives the error
Input In [39]
"""
^
SyntaxError: f-string: expecting '}'
I want it to print {
as it is
Solution 1:[1]
You can try:
test = f"""{{"""
print(test)
or
test = f"{'{'}"
print(test)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |