isnumeric (mhlib.py)

Remco Gerlich scarblac at pino.selwerd.nl
Fri Jan 12 02:30:45 EST 2001


Richard van de Stadt <stadt at cs.utwente.nl> wrote in comp.lang.python:
> I needed a function to check if a string is a number.

If you are using Python 1.6 or 2.0, strings have the isdigit() method:

>>> x = "0"
>>> x.isdigit()
1
>>> x = "1234"
>>> x.isdigit()
1
>>> x = "1234a"
>>> x.isdigit()
0

-- 
Remco Gerlich



More information about the Python-list mailing list