The IsDigit function under Python:
the IsDigit () method detects whether a string consists of only numbers.
Grammar
IsDigit () method syntax: str. IsDigit()
The sample code is as follows:
Results:
The point I want to say is:
There's going to be a hole in there. Number = input ("1234:") gets a string of values from the console
Then there is
Python input () is equal to eval (raw_input (Prompt)), which is used to get input from the console.
Raw_input () treats all input as a string and returns the string type. Input (), when treated with a pure numeric input, has its own characteristics, which returns the type of the number entered (int, float).
When entering the full numeric string, this time the use of number.isdigit () will be an error (attributeerror: ' int ' object has no attribute ' isdigit '), is already a value of type int, in using this function, Must be an error.
Then it is best to choose the Raw_input () function, as the dynamic input method, the responsibility will fall into the pit.
Attributeerror: ' int ' object has no attribute ' isdigit ' (isdigit function under Python)