Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 what's really wrong with this f-string?
#1
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 >>>
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#2
In the format() syntax, one escapes curly braces by doubling them. It should probably be s=f'{a} "{{"'
Skaperen likes this post
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)