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

PythonServer Side ProgrammingProgramming

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
raja
Published on 08-Dec-2017 16:08:19
Advertisements