About 50 results
Open links in new tab
  1. String formatting in Python - Stack Overflow

    Use Python 3 string formatting. This is still available in earlier versions (from 2.6), but is the 'new' way of doing it in Py 3. Note you can either use positional (ordinal) arguments, or named arguments (for the …

  2. python - String formatting: % vs. .format vs. f-string literal - Stack ...

    For reference: Python 3 documentation for the newer format() formatting style and the older % -based formatting style.

  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. How to print a number using commas as thousands separators

    How do I print an integer with commas as thousands separators? 1234567 1,234,567 It does not need to be locale-specific to decide between periods and commas.

  5. python - Format string with custom delimiters - Stack Overflow

    Using custom placeholder tokens with python string.format() Context python 2.7 string.format() alternative approach that allows custom placeholder syntax Problem We want to use custom …

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

    Apr 15, 2011 · 238 The string format method lets you do some fun stuff with nested keyword arguments. The simplest case:

  7. python - 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. python - String formatting named parameters? - Stack Overflow

    47 Solution in Python 3.6+ Python 3.6 introduces literal string formatting, so that you can format the named parameters without any repeating any of your named parameters outside the string:

  9. What does %s mean in a Python format string? - Stack Overflow

    253 It is a string formatting syntax (which it borrows from C). Please see "PyFormat": Python supports formatting values into strings. Although this can include very complicated expressions, the most …

  10. python - Display number with leading zeros - Stack Overflow

    str(number).rjust(string_width, fill_char) This way, the original string is returned unchanged if its length is greater than string_width. Example: