Computer >> Computer tutorials >  >> Programming >> Python

How to check if a unicode string contains only numeric characters in Python?


If we want to check if a unicode string contains only numeric characters, we can use the special method isnumeric() that exists solely for checking unicode strings. You can use it as follows −

Example

print(u"1234".isnumeric())
print(u"1,a234".isnumeric())

Output

True
False