How to test if object is an integer?
Ian Kelly
ian.g.kelly at gmail.com
Mon Oct 17 17:49:08 EDT 2011
On Mon, Oct 17, 2011 at 2:44 PM, Noah Hall <enalicho at gmail.com> wrote:
> There's the isdigit method, for example -
>
>>>> str = "1324325"
>>>> str.isdigit()
> True
>>>> str = "1232.34"
>>>> str.isdigit()
> False
>>>> str = "I am a string, not an int!"
>>>> str.isdigit()
> False
That works for non-negative base-10 integers. But:
>>> "-1234".isdigit()
False
Cheers,
Ian
More information about the Python-list
mailing list