There are differences, but they're somewhat rare*. It mainly crops up with various unicode characters, such as 2
:
>>> c = 'u00B2'
>>> c.isdecimal()
False
>>> c.isdigit()
True
You can also go further down the careful-unicode-distinction rabbit hole with the isnumeric
method:
>>> c = 'u00BD' # ?
>>> c.isdecimal()
False
>>> c.isdigit()
False
>>> c.isnumeric()
True
*At least, I've never encountered production code that needs to distinguish between strings that contain different types of these exceptional situations, but surely use cases exist somewhere.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…