About 305,000 results
Open links in new tab
  1. python - What is print (f"...") - Stack Overflow

    Jul 22, 2019 · A formatted string literal or f-string is a string literal that is prefixed with f or F. These strings may contain replacement fields, which are expressions delimited by curly braces …

  2. What does 'f' mean before a string in Python? - Stack Overflow

    Oct 4, 2019 · This is called f-strings and are quite straightforward : when using an "f" in front of a string, all the variables inside curly brackets are read and replaced by their value.

  3. How do I convert a string into an f-string? - Stack Overflow

    f-strings are new in python 3.6 and are literals not callables. I know how to get something that works similarly. What I want is to make an existing string (possibly loaded from a file) and have …

  4. python - How to escape curly-brackets in f-strings? - Stack Overflow

    Desired result: 'test {bar}' Edit: Looks like this question has the same answer as How can I print literal curly-brace characters in a string and also use .format on it?, but you can only know that …

  5. python - Using f-string with format depending on a condition

    Aug 16, 2018 · How can I use f-string with logic to format an int as a float? I would like if ppl is True to format num to 2 decimal places, and if ppl is False to rformat it as whatever it is. …

  6. python - What are use cases for nested f-strings - Stack Overflow

    I don't think formatted string literals allowing nesting (by nesting, I take it to mean f'{f".."}') is a result of careful consideration of possible use cases; I'm more convinced it's just allowed in …

  7. python - How can I use newline '\n' in an f-string to format a list of ...

    Jun 27, 2017 · The other answers give ideas for how to put the newline character into a f-string field. However, I would argue that for the example the OP gave (which may or may not be …

  8. How do I escape curly-brace ( {}) characters characters in a string ...

    It is the first result that comes up when you google how to put curly braces in python f-strings though, and yes I agree it's not pretty but sometimes you just need it.

  9. f-string syntax for unpacking a list with brace suppression

    Mar 13, 2017 · For me, the hoops you have to jump through to construct your format string make it considerably less readable than the f-string alternative presented here – which uses a very …

  10. python - Fixed digits after decimal with f-strings - Stack Overflow

    Apr 19, 2020 · Is there an easy way with Python f-strings to fix the number of digits after the decimal point? (Specifically f-strings, not other string formatting options like .format or %) For …

Refresh