-1
The method 'str'.isdigit()
will always return the same T/F as isdecimal() or there is some difference in the algorithm of these methods?
-1
The method 'str'.isdigit()
will always return the same T/F as isdecimal() or there is some difference in the algorithm of these methods?
1
It is mainly about Unicode classifications. See some examples to show discrepancies:
>>> def spam(s):
... for attr in 'isnumeric', 'isdecimal', 'isdigit':
... print(attr, getattr(s, attr)())
...
>>> spam('½')
isnumeric True
isdecimal False
isdigit False
>>> spam('³')
isnumeric True
isdecimal False
isdigit True
Check out the full answer here https://stackoverflow.com/a/44891216/4007642
Browser other questions tagged python
You are not signed in. Login or sign up in order to post.