str.isnumeric()
str.isnumeric() Returns:
bool · Added in v3.x · Updated March 13, 2026 · String Methods stdlib string validation
The isnumeric() method checks whether all characters in a string are numeric characters and the string contains at least one character. It returns a boolean value—True if every character has a numeric value property in Unicode, False otherwise.
This method is useful when you need to validate numeric input that might include Unicode characters like fractions, roman numerals, or subscript/superscript digits.
Syntax
str.isnumeric()
Parameters
This method takes no parameters.
Examples
Basic usage
>>> "12345".isnumeric()
True
>>> "12.34".isnumeric()
False
>>> "".isnumeric()
False
>>> "abc".isnumeric()
False
Unicode numeric characters
Python 3 supports various Unicode characters that have numeric value properties:
>>> "Ⅶ".isnumeric() # Roman numeral seven
True
>>> "ⅱ".isnumeric() # Small Roman numeral two
True
>>> "½".isnumeric() # Vulgar fraction one-half
True
>>> "²".isnumeric() # Superscript two
True
Characters that fail
>>> "12.34".isnumeric() # Decimal point
False
>>> "-50".isnumeric() # Minus sign
False
>>> "1,000".isnumeric() # Comma
False
>>> " 123".isnumeric() # Leading space
False
Common Patterns
Validating numeric input with Unicode support
def extract_numeric(text):
"""Extract all numeric characters from a string."""
return ''.join(c for c in text if c.isnumeric())
>>> extract_numeric("Room 302B")
'302'
>>> extract_numeric("Call 555-1234")
'5551234'
>>> extract_numeric("Price: €50½")
'50½'
Processing international numeric data
def is_numeric_entry(value):
"""Check if entry contains only numeric characters."""
return value.isnumeric() and len(value) > 0
>>> is_numeric_entry("123")
True
>>> is_numeric_entry("ⅠⅡⅢ") # Roman numerals
True
>>> is_numeric_entry("①②③") # Enclosed numbers
True
>>> is_numeric_entry("")
False
Differences Between isdigit, isnumeric, and isdecimal
These three methods have subtle but important differences:
| Method | Accepts | Example |
|---|---|---|
isdigit() | 0-9, superscripts | ² → True |
isnumeric() | isdigit() + fractions + Roman numerals | ½ → True, Ⅶ → True |
isdecimal() | 0-9 only (strict) | ½ → False |
>>> "²".isdigit(), "²".isnumeric(), "²".isdecimal()
(True, True, False)
>>> "½".isdigit(), "½".isnumeric(), "½".isdecimal()
(False, True, False)
Behavior Notes
- Returns False for empty strings—the string must contain at least one character
- Accepts any Unicode character with numeric value property (Nd, Nl, No categories)
- Does not accept minus signs, decimal points, commas, or other numeric punctuation
- Roman numerals are considered numeric (category Nl)
- Fractions like ½ and ⅕ are considered numeric
See Also
- str::isdigit — checks if all characters are digit characters
- str::isdecimal — checks if all characters are decimal digits (strict base-10)
- str::isalnum — checks if all characters are alphanumeric