Python isnumeric() method
Description
The Python isnumeric() method checks whether a string consists only of numeric characters. This method is only for unicode objects.
**Note:** To define a string as Unicode, simply add the 'u' prefix before the string; see the examples in this chapter for details.
Syntax
Syntax of the isnumeric() method:
str.isnumeric()
Parameters
- none.
Return Value
Returns True if the string contains only numeric characters, otherwise False
Example
The following example shows how to use the isnumeric() method:
#!/usr/bin/python
str = u"this2009";
print str.isnumeric();
str = u"23443434";
print str.isnumeric();
The output of the above example is:
False
True
Python Strings