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

    Jun 23, 2019 · For Python 3.6, you can use the f-strings new feature to convert to string and it's faster compared to str() function. It is used like this: It is used like this: age = 45 strAge = f'{age}'

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

    Dec 19, 2008 · As a general rule, if you have an object in Python, and want to convert to that type of object, call type(my_object) on it. The result can usually be called as a function to do the …

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

    Edit: Your division function might also result in some sad faces if you aren't fully aware of how python 2.x handles integer division. In short, if you want 10/2 to equal 2.5 and not 2, you'll …

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

    There are several methods to convert string numbers in a list to integers. In Python 2.x you can use the map function: >>> results = ['1', '2', '3'] >>> results = map(int, results) >>> results [1, 2, …

  5. Convert a string to integer with decimal in Python

    Matt, 23.45678 isn't an integer. If you want Python to convert a string to an integer, make sure that you give it an integer. Arguments can be made either way about what the "right" thing is, …

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

    Jul 30, 2022 · @Max the 16 is for base 16.Normally people use base 10 (and in Python there's an implicit 10 when you don't pass a second argument to int()), where you start at 0 then count up …

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

    Nov 10, 2011 · In many cases, we want to get an integer value from the user. Users may insert non-integer values that should be warned and they should be prompted to try again. The …

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

    Dec 8, 2013 · Python 2's input function evaluated the received data, converting it to an integer implicitly (read the next section to understand the implication), but Python 3's input function …

  9. string - Typecasting in Python - Stack Overflow

    May 1, 2016 · I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings.

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

    Mar 15, 2011 · Use int which converts a string to an int, inside a list comprehension, like this: desired_array = [int(numeric_string) for numeric_string in current_array] Share

Refresh