我遇到了以下问题f-string:
>>> a='hello'
# how to print '{hello}' ?
>>> f'{{a}}'
'{a}'
>>> f'\{{a}\}'
File "<stdin>", line 1
SyntaxError: f-string: single '}' is not allowed
# doing it without f-strings
>>> '{' + a + '}'
'{hello}'
Run Code Online (Sandbox Code Playgroud)
如何转义 fstring 中的字符?