all Python 3Strings (str)function
str.isnumeric
character checks
True if all characters are numeric, including fractions and numerals (½, Ⅴ).
Syntax
s.isnumeric()
The widest of the three checks: fractions and Roman numerals return True even though neither int() nor float() can parse them. To get the value of such a character use unicodedata.numeric(); to validate input before int() use isdecimal instead.
Examples
print('123'.isnumeric()) # → True
print('½'.isnumeric()) # → True
print('1.2'.isnumeric()) # → False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy