About 401,000 results
Open links in new tab
  1. String formatting in Python - Stack Overflow

    I want to do something like String.Format("[{0}, {1}, {2}]", 1, 2, 3) which returns: [1, 2, 3] How do I do this in Python?

  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. What does %s mean in a Python format string? - Stack Overflow

    Mar 1, 2022 · Actually that PEP says "In Python 3.0, the % operator is supplemented by a more powerful string formatting method" and that it is backported to Python 2.6. Where I come from …

  4. How to include the symbol " {" in a Python format string?

    Mar 22, 2013 · Format strings contain “replacement fields” surrounded by curly braces {}. Anything that is not contained in braces is considered literal text, which is copied unchanged to …

  5. string - How to format a floating number to fixed width in Python ...

    How do I format a floating number to a fixed width with the following requirements: Leading zero if n < 1 Add trailing decimal zero(s) to fill up fixed width Truncate decimal digits past fixed w...

  6. 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.

  7. String formatting in python 2.7 - Stack Overflow

    Jul 13, 2015 · 1 In scenario 1, python does an implicit cast from integer to double. So far so good. In scenario 2, python does an implicit cast from integer to string, which is possible. However in …

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

    1979 In Python 2 (and Python 3) you can do: number = 1 print("%02d" % (number,)) Basically % is like printf or sprintf (see docs). For Python 3.+, the same behavior can also be achieved with …

  9. Format numbers to strings in Python - Stack Overflow

    2 You can use the str.format () to make Python recognize any objects to strings.

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

    The OP wants to keep curly-braces while you are removing them in your linked answer via .format () and your dictionary unpacking method. If you want to preserve {} in Python 3.6+ and you …

Refresh