About 173,000 results
Open links in new tab
  1. Convert integer to string in Python - Stack Overflow

    Jun 23, 2019 · In the above program, int() is used to convert the string representation of an integer. Note: A variable in the format of string can be converted into an integer only if the …

  2. python - How do I parse a string to a float or int? - Stack Overflow

    Dec 19, 2008 · In Python, how can I parse a numeric string like "545.2222" to its corresponding float value, 542.2222? Or parse the string "31" to an integer, 31? I just want to know how to …

  3. How can I convert a string to an int in Python? - Stack Overflow

    converting string to int python. 1. convert string to int? 0. String to Int conversion in python. 1.

  4. python - How do I pad a string with zeros? - Stack Overflow

    Dec 3, 2008 · What is the most pythonic way to pad a numeric string with zeroes to the left, i.e., so the numeric string has a specific length? str.zfill is specifically intended to do this: >>> …

  5. python - Best way to format integer as string with leading zeros ...

    Python: list range: int to string conversion. 27. In Python, how to specify a format when converting int ...

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

    All of these create the string "01": >python -m timeit "'{:02d}'.format(1)" 1000000 loops, best of 5: 357 nsec per loop >python -m timeit "'{0:0{1}d}'.format(1,2)" 500000 loops, best of 5: 607 nsec …

  7. How to get integer values from a string in Python?

    this approach uses list comprehension, just pass the string as argument to the function and it will return a list of integers in that string. def getIntegers(string): numbers = [int(x) for x in …

  8. python - How to change any data type into a string ... - Stack …

    Jul 8, 2010 · The rule of thumb for repr is that if it makes sense to return Python code that could be evaluated to produce the same object, do that, just like str, frozenset, and most other …

  9. python - How to check if a variable is an integer or a string?

    The latter will not detect all valid int() values, as whitespace and + and -are also allowed in int() values. The first form will happily accept ' +10 ' as a number, the latter won't. If your expect …

  10. python - How can I check if a string represents an int, without …

    Safely evaluate an expression node or a string containing a Python literal or container display. The string or node provided may only consist of the following Python literal structures: strings, …