About 174,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 - How can I format a decimal to always show 2 decimal …

    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 …

  3. What are the most common Python docstring formats?

    Formats Python docstrings can be written following several formats as the other posts showed. However the default Sphinx docstring format was not mentioned and is based on …

  4. What is the proper way to comment functions in Python?

    Mar 2, 2010 · 6 Read about using docstrings in your Python code. As per the Python docstring conventions: The docstring for a function or method should summarize its behavior and …

  5. Converting integer to binary in Python - Stack Overflow

    10 The best way is to specify the format. format(a, 'b') returns the binary value of a in string format. To convert a binary string back to integer, use int () function. int('110', 2) returns …

  6. python - How to print a percentage value? - Stack Overflow

    Mar 15, 2011 · Given a float between 0 and 1, how to print it as a percentage? For example, 1/3 should print as 33%.

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

  8. Rounding decimals with new Python format function

    Oct 21, 2009 · How do I round a decimal to a particular number of decimal places using the Python 3.0 format function?

  9. JavaScript equivalent of Python's format () function?

    The format function takes an array of values as its parameter, with each key being one of the bracketed 'variables' which is replaced by its corresponding value.

  10. Using variables in the format() function in Python

    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 …