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()
.
More Related Contents:
- How do I check if a string is a number (float)?
- How do I parse a string to a float or int?
- Import pandas dataframe column as string not int
- Convert Python strings into floats explicitly using the comma or the point as separators
- Pandas reading csv as string type
- Python casting error: Invalid literal for int() with base 10
- Change column type in pandas
- Is floating point arbitrary precision available?
- NumPy or Pandas: Keeping array type as integer while having a NaN value
- Python JSON serialize a Decimal object
- How to display a float with two decimal places?
- Limiting floats to two decimal points
- How to get a random number between a float range?
- How to get numbers after decimal point?
- round() doesn’t seem to be rounding properly
- negative zero in python
- Easy pretty printing of floats?
- How do I use a decimal step value for range()?
- Float values as dictionary key
- Rounding a number in Python but keeping ending zeros
- Convert float to string in positional format (without scientific notation and false precision)
- Comparing floats in a pandas column
- overriding bool() for custom class [duplicate]
- Why do simple math operations on floating point return unexpected (inaccurate) results in VB.Net and Python?
- Converting integer to digit list
- Determine precision and scale of particular number in Python
- Why does the floating-point value of 4*0.1 look nice in Python 3 but 3*0.1 doesn’t?
- Python float to int conversion
- HTML to IMAGE using Python
- How do you get the next value in the floating-point sequence? [duplicate]