Python isdigit () is True for ④, but int () is not working

What is the difference between 𝟜 and ④?

>>> u'𝟜'.isdigit() True >>> int(u'𝟜') 4 >>> u'④'.isdigit() True >> int(u'④') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: '④' 

Note: the above is output in python3. In the latter case, python gives the following exception:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'decimal' codec can't encode character u'\u2463' in position 0: invalid decimal Unicode string 
+5
source share

Source: https://habr.com/ru/post/1204355/


All Articles