About 50 results
Open links in new tab
  1. How do I check if a string represents a number (float or int)?

    Lets say that if the string is likely to be a number the try/except strategy is the fastest possible.If the string is not likely to be a number and you are interested in Integer check, it worths to do some test …

  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 duplicate …

  3. 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 function:

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

    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 to a string. The …

  5. Convert hex string to integer in Python - Stack Overflow

    Oct 16, 2008 · 60 Convert hex string to int in Python I may have it as "0xffff" or just "ffff". To convert a string to an int, pass the string to int along with the base you are converting from. Both strings will …

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

  7. Converting String to Int using try/except in Python

    Nov 10, 2011 · So I'm pretty stumped on how to convert a string into an int using the try/except function. Does anyone know a simple function on how to do this? I feel like I'm still a little hazy on string and i...

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

    How do I pad a numeric string with zeroes to the left, so that the string has a specific length?

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

    Now that info has to be strictly an integer or a string, depending on the situation. However, whatever you type into Python using raw_input () actually is a string, no matter what, so more specifically, how …

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

    Suppose I had a string string1 = "498results should get" Now I need to get only integer values from the string like 498. Here I don't want to use list slicing because the integer values may incr...