The method isnumeric()
will do the job (Documentation for python3.x):
>>>a = '123'
>>>a.isnumeric()
True
But remember:
>>>a = '-1'
>>>a.isnumeric()
False
isnumeric()
returns True if all characters in the string are numeric characters, and there is at least one character.
So negative numbers are not accepted.