For non-negative (unsigned) integers only, use isdigit()
:
>>> a = "03523"
>>> a.isdigit()
True
>>> b = "963spam"
>>> b.isdigit()
False
Documentation for isdigit()
: Python2, Python3
For Python 2 Unicode strings:
isnumeric()
.
For non-negative (unsigned) integers only, use isdigit()
:
>>> a = "03523"
>>> a.isdigit()
True
>>> b = "963spam"
>>> b.isdigit()
False
Documentation for isdigit()
: Python2, Python3
For Python 2 Unicode strings:
isnumeric()
.