About 193,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 variable is …

  2. 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 returned. Edit: …

  3. Convert a string to integer with decimal in Python

    I believe this is a useless bug that should be corrected in Python. int('2') --> 2 That converts the string '2' into an the integer 2. int(2.7) --> 2 Converts a float to an int. int('2.7') SHOULD convert to 2. This is …

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

    13 There are several methods to convert string numbers in a list to integers. In Python 2.x you can use the map function:

  5. Python String to Int Or None - Stack Overflow

    @Nickolay "String" almost always means str. See the docs for example: "Textual data in Python is handled with str objects, or strings." Including bytes too is fine since there's historical precedent from …

  6. python - How can I check if a string represents an int, without using ...

    I've updated the code above to work in Python 3.5, and to include the check_int function from the currently most voted up answer, and to use the current most popular regex that I can find for testing …

  7. python - Pandas convert string to int - Stack Overflow

    10 If you're here because you got OverflowError: Python int too large to convert to C long use .astype('int64') for 64-bit signed integers:

  8. 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 Python …

  9. python - How to make "int" parse blank strings? - Stack Overflow

    I wanted to handle it by defining a subclass of int that handles blank strings. This way I could go and change the type of appropriate table entries without introducing additional kludges in the parsing …

  10. python - Is there a way to convert number words to Integers? - Stack ...

    I need to convert one into 1, two into 2 and so on. Is there a way to do this with a library or a class or anything?