Dec 24, 2020

[python3] s.isdigit() vs. s.isnumeric() vs. s.isdecimal()

Reference:


>>> 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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.