About 206,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 parse a float string to a float, and (separately) an int string 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. 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]

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

    Safely evaluate an expression node or a string containing a Python literal or container display. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None.

  5. 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 with any object that has a method called __str__() defined. In fact. str(a) is equivalent to. a.__str__() The same if you want to convert something to int, float, etc.

  6. 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:

  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. python - Convert String to Int without int () - Stack Overflow

    Jul 4, 2014 · How to convert string to int in python? 0. Convert string to int value python. 1.

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

    Nov 10, 2011 · print '"%s" cannot be converted to an int: %s' % (value, ex) ... 12345 as an int is 12345 67890 as an int is 67890 3.14 as an int is 3 42 as an int is 42 21 as an int is 21 254 as an int is 254 "Not convertible" cannot be converted to …

  10. Convert string / character to integer in python - Stack Overflow

    Jun 30, 2017 · Ah, ok. My two cents on making stuff not sound like homework, if you're so inclined: only post the part of the problem you want answered (like "how do I convert a character to an int in python" rather than the full question which I actually remember as being one of the first questions in my cryptography class in school) and also, I think just saying "This might sound like homework, but it's ...

Refresh