This article mainly introduces how to use the isnumeric () method in Python. the use of the isnumeric () method is the basic knowledge in Python. For more information, see isnumeric () method to check whether a string is composed of only numbers. This method is only represented as a Unicode object.
Note: to define a string as Unicode, you only need to assign 'U' quotation marks with the prefix. The following is an example.
Syntax
The syntax of the isnumeric () method is as follows:
Str. isnumeric ()
Parameters
Return value
Returns true if all characters in the string are numbers. otherwise, returns false.
Example
The following example shows how to use the isnumeric () method.
#! /Usr/bin/pythonstr = u "this2009"; print str. isnumeric (); str = u "23443434"; print str. isnumeric ();
When we run the above program, it will produce the following results:
FalseTrue