About 424,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 · For the reverse, see Convert integer to string in Python and Converting a float to a string without rounding it. Please instead use How can I read inputs as numbers? to close …

  3. python - How to convert an integer to a string in any base? - Stack ...

    The below provided Python code converts a Python integer to a string in arbitrary base ( from 2 up to infinity ) and works in both directions. So all the created strings can be converted back to …

  4. How to change any data type into a string? - Stack Overflow

    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 …

  5. python - Convert all strings in a list to integers - Stack Overflow

    8 You can easily convert string list items into int items using loop shorthand in python Say you have a string result = ['1','2','3'] Just do,

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

    def convertStr(s): """Convert string to either int or float.""" try: ret = int(s) except ValueError: #Try float. ret = float(s) return ret That way if the int conversion doesn't work, you'll get a float …

  7. Convert int to binary string in Python - Stack Overflow

    Apr 30, 2019 · How do I convert an integer into a binary string in Python? 37 → '100101'

  8. Format numbers to strings in Python - Stack Overflow

    0 str () in python on an integer will not print any decimal places. If you have a float that you want to ignore the decimal part, then you can use str (int (floatValue)). Perhaps the following code …

  9. python - How can I read inputs as numbers? - Stack Overflow

    Dec 8, 2013 · 403 Since Python 3, input returns a string which you have to explicitly convert to int, like this

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

    The built-in int () function silently truncates the fractional part of a floating point number and returns the integer part before the decimal, unless the floating point number is first converted …