About 232,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 · In Python, how can I parse a numeric string like "545.2222" to its corresponding float value, 542.2222? Or parse the string "31" to an integer, 31? I just want to know how to …

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

    How to convert string to int in python? 7. Convert String to Int without int() 0.

  3. Convert integer to string in Python - Stack Overflow

    Jun 23, 2019 · 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 …

  4. python - How to change any data type into a string ... - Stack …

    Jul 8, 2010 · str is meant to produce a string representation of the object's data. If you're writing your own class and you want str to work for you, add:

  5. Python: Convert a string to an integer - Stack Overflow

    Mar 27, 2014 · Does anybody have a quickie for converting an unsafe string to an int? The string typically comes back as: '234\r\n' or something like that. In this case I want 234. If '-1\r\n', I …

  6. 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, 3]

  7. 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 ... Convert bytes to a string in Python 3.

  8. Convert a string to integer with decimal 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 how Perl works, for example. Yes, this does two things …

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

    I want to convert to int without using loops - for this I use ID.astype(int). The problem is that some of my lines contain dirty data which cannot be converted to int , for e.g. ID[154382] Out[58]: …

  10. How to convert numpy array elements from string to int

    I have a list of numbers in string format. I converted that list into numpy array using np.asarray(). How do I convert the string elements to ints?

Refresh