Python 3 reference · String Methods
Python String isnumeric() Method
Return True if every character is numeric, including digits, fractions like ½ and numerals from other scripts.
Python 3 Since 3.0
Syntax
str.isnumeric()
Return value
True or False.
Examples
for s in ["42", "½", "Ⅻ", "4.5"]:
print(repr(s), s.isnumeric())
Output
'42' True '½' True 'Ⅻ' True '4.5' False
print("½".isnumeric(), "½".isdigit(), "½".isdecimal())
Output
True False False
Version history
| Version | Change |
|---|---|
| Python 3.0 | Added |
Related
str.isdecimal()· Return True if every character is a decimal digit (0–9 and their equivalents in other scripts). The strictest digit check.str.isdigit()· Return True if every character is a digit, including superscripts like ². Signs, spaces and decimal points return False.- Python Strings · tutorial