About 542,000 results
Open links in new tab
  1. What's the difference between str.isdigit (), isnumeric () and ...

    52 The Python documentation notes the difference between the three methods. str.isdigit Return true if all characters in the string are digits and there is at least one character, false otherwise. Digits …

  2. python - How can I check if string input is a number? - Stack Overflow

    How do I check if a user's string input is a number (e.g., -1, 0, 1, etc.)? user_input = input ("Enter something:") if type (user_input) == int: print ("Is a number") else:

  3. How do I check if a string represents a number (float or int)?

    How do I check if a string represents a numeric value in Python? def is_number(s): try: float(s) return True except ValueError: return False The above works, but it...

  4. python - Why isn't isnumeric working? - Stack Overflow

    Apr 20, 2014 · if using python 3 wrap string around str as shown below str ('hello').isnumeric () This way it behaving as expected

  5. python - Testing if a value is numeric - Stack Overflow

    Jul 25, 2015 · How can we write a test that checks if a value is numeric, and throw an exception is the value is not numeric? Do we need regular expressions in this case? Thanks.

  6. how to find if any character in a string is a number in python ...

    Mar 9, 2022 · I need to determine if there are alphabetic and numeric characters in a string. My code for testing the alphabetic one seems to work fine, but numeric is only working if all of the characters are a...

  7. Python: how do I use isnumeric () - Stack Overflow

    Mar 7, 2019 · Can someone kindly explain why the following throws an exception? And what should I do with variable s to find out whether it contains a number? s = str(10) if s.isnumeric(): print s When I read

  8. Python: is isalnum () the same as isalpha with isdigit?

    Jun 11, 2016 · From the documentation of Python 3: str.isalnum() Return true if all characters in the string are alphanumeric and there is at least one character, false otherwise. A character c is …

  9. python - How to determine whether a column/variable is numeric or …

    Apr 11, 2018 · Is there a better way to determine whether a variable in Pandas and/or NumPy is numeric or not ? I have a self defined dictionary with dtypes as keys and numeric / not as values.

  10. What is a reliable isnumeric () function for python 3?

    I am attempting to do what should be very simple and check to see if a value in an Entry field is a valid and real number. The str.isnumeric() method does not account for "-" negative numbers, or "."