Python Forum
what's really wrong with this f-string? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: what's really wrong with this f-string? (/thread-22128.html)



what's really wrong with this f-string? - Skaperen - Oct-31-2019

what's really wrong with this f-string? the quotes look right so it must be the backslash.
Output:
>>> a=432 >>> s=f'{a} "\{"' File "<stdin>", line 1 SyntaxError: f-string: unterminated string >>>



RE: what's really wrong with this f-string? - Gribouillis - Oct-31-2019

In the format() syntax, one escapes curly braces by doubling them. It should probably be s=f'{a} "{{"'