About 129,000 results
Open links in new tab
  1. python - String formatting: % vs. .format vs. f-string literal - Stack ...

    158 Assuming you're using Python's logging module, you can pass the string formatting arguments as arguments to the .debug() method rather than doing the formatting yourself:

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

    18 f-strings (python 3) You can avoid having to double the curly brackets by using f-strings ONLY for the parts of the string where you want the f-magic to apply, and use regular (dumb) strings …

  3. Format numbers to strings in Python - Stack Overflow

    Starting with Python 3.6, formatting in Python can be done using formatted string literals or f-strings:

  4. String formatting in Python - Stack Overflow

    20 You're looking for string formatting, which in python is based on the sprintf function in C.

  5. python - Format string dynamically - Stack Overflow

    If I want to make my formatted string dynamically adjustable, I can change the following code from

  6. Using variables in the format() function in Python - Stack Overflow

    Sep 5, 2015 · The advantage of using a regular string template and str.format() is that you can swap out the template, the advantage of f-strings is that makes for very readable and compact …

  7. How to print formatted string in Python3? - Stack Overflow

    Use f-strings if you just need to format something on the spot to print or create a string for other reasons, str.format() to store the template string for re-use and then interpolate values.

  8. String formatting in python 2.7 - Stack Overflow

    Jul 13, 2015 · It's because of that %s converts another python types to string using str() function. but %d just accept an integer decimal. For more information read String Formatting Operations.

  9. How can I fill out a Python string with spaces? - Stack Overflow

    Apr 15, 2011 · 1036 You can do this with str.ljust(width[, fillchar]): Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is a space). The …

  10. How do I create a multiline Python string with inline variables?

    Alternatively, you can also create a multiline f-string with triple quotes where literal newlines are considered part of the string. However, any spaces at the start of the line would also be part of …