About 177,000 results
Open links in new tab
  1. 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 …

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

    Here, append () is used to add items ( i.e integer version of string (i) in this program ) to the end of the list (b). Note: int () is a function that helps to convert an integer in the form of string, back to …

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

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

    Dec 8, 2013 · Here is the Python 3 version: a = [] p = input() p = p.split() for i in p: a.append(int(i)) You can also use list comprehensions: p = input().split("whatever the seperator is") To convert …

  5. Convert integer to string in Python - Stack Overflow

    Jun 23, 2019 · 72 There is no typecast and no type coercion in Python. You have to convert your variable in an explicit way. To convert an object into a string you use the str() function. It works …

  6. Python: How do I convert an array of strings to an array of numbers?

    Mar 15, 2011 · MATHY people call Python lists an array. A 2-d list/array is a matrix. I believe the origin is from linear algebra.

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

    Oct 16, 2008 · Worth repeating "Letting int infer If you pass 0 as the base, int will infer the base from the prefix in the string." How to convert from hexadecimal or decimal (or binary) to integer …

  8. python - How can I convert string values from a dictionary, into int ...

    Mar 16, 2011 · Check if the element is a dictionary, if it is, use the recursive update. If it's able to be converted into a float or int, convert it and modify the value in the dictionary. There isn't any …

  9. python - How to convert a string to a number if it has commas in …

    It will be converted to string first (if it is a list, for example from Beautiful soup); then to int, then to float. It goes as far as it can get. In worst case, it returns everything unconverted as string. def …

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