About 50 results
Open links in new tab
  1. 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.

  2. Format numbers to strings in Python - Stack Overflow

    The OP & accepted answer focus on formatting time, but the OP question itself discusses formatting numbers to strings in Python. In many cases, the output requires additional data fields be included …

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

    Context python 2.7 string.format() alternative approach that allows custom placeholder syntax Problem We want to use custom placeholder delimiters with python str.format () string.format() is powerful, but …

  4. Python way of printing: with 'format' or percent form?

    Sep 12, 2012 · Use the format method, especially if you're concerned about Python 3 and the future. From the documentation: The formatting operations described here are modelled on C's printf() …

  5. python - How can I format a decimal to always show 2 decimal places ...

    the Python String Format Cookbook: shows examples of the new-style .format() string formatting pyformat.info: compares the old-style % string formatting with the new-style .format() string …

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

    Python supports formatting values into strings. Although this can include very complicated expressions, the most basic usage is to insert values into a string with the %s placeholder.

  7. How do I format a string using a dictionary in python-3.x?

    91 As Python 3.0 and 3.1 are EOL'ed and no one uses them, you can and should use str.format_map(mapping) (Python 3.2+): Similar to str.format(**mapping), except that mapping is …

  8. Python string.format () percentage without rounding

    May 5, 2020 · With Python 3.6+, you can use formatted string literals, also known as f-strings. These are more efficient than str.format. In addition, you can use more efficient floor division instead of …

  9. datetime - ISO time (ISO 8601) in Python - Stack Overflow

    In Python, I would like to take its creation time, and convert it to an ISO time (ISO 8601) string while preserving the fact that it was created in the Eastern Time Zone (ET). How do I take the file's ctime …

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

    Works in Python 2.7.5 as well. You can also use ' {:02d}'.format (1) if you don't want to use named arguments.