Latest web development tutorials

Python isnumeric () method

Python strings Python strings


description

Are Python isnumeric () method to detect a string consisting of only numbers. This method is only for unicode object.

Note: The definition of a string of Unicode, just before the string with 'u' prefix can be, you can view the specific examples in this section.

grammar

isnumeric () method syntax:

str.isnumeric()

parameter

  • no.

return value

If the string contains only numeric characters, it returns True, otherwise False

Examples

The following example shows an example of isnumeric () method:

#!/usr/bin/python


str = u"this2009";  
print str.isnumeric();

str = u"23443434";
print str.isnumeric();

Examples of the above output results are as follows:

False
True

Python strings Python strings