This article focuses on the use of the IsNumeric () method in Python, the use of the IsNumeric () method is the basic knowledge of Python introduction, the need for friends can refer to the
The IsNumeric () method checks whether the string is composed of numbers only. This method is only represented as a Unicode object.
Note: To define a string as Unicode, simply prefix the ' u ' quote. The following is an example.
The following is the syntax for the IsNumeric () method:
If all characters in a string are numbers this method returns True, otherwise returns false.
The following example shows the use of the IsNumeric () method.
|1 2 3 4 5 6 7 8||#!/usr/bin/python str = u "this2009"; Print str.isnumeric (); str = u "23443434"; Print str.isnumeric ();|
When we run the above program, it produces the following results:
|1 2||False True|