How and why does the language depend on string.isdigit ()?

Python has a function for the line to check whether all the symbols in figures: string.isdigit().

The manual says:

For 8-bit strings, this method is language dependent

How is this locale-depedent method? What locales have numbers outside the range 0-9?

Also, if it depends on the language, python has a method for checking it with a specific locale (i.e. only 0-9 digits).

+5
source share
2 answers

CPython uses the C function isdigit for the is_digit method for strings (see stringobject.c). See this related topic: Can isdigit legally language dependent in C

-, , 0xB2 ('²'), 0xB3 ('³') 0xB9 ('¹').

+4

python ( 0-9 ).

:

>>> '1' in '1234567890'
True
>>> 'a' in '1234567890'
False

ord, ():

>>> ord('0') <= ord('a') <= ord('9')
False
>>> ord('0') <= ord('5') <= ord('9')
True
+1

All Articles