В продолжение прошлого поста про цифры в мире строк.
Почему методы isdigit() и isnumeric() не определяют в строке float и отрицательные значения?
Дело в том, что эти методы работают с ЦИФРАМИ, то есть с единичным символом. А строка "-2" или "3.4" это уже ЧИСЛО. То есть не символ а значение, записанное несколькими символами.
Все озвученные методы проходятся по каждому символу строки и проверяют их индивидуально.
В юникоде есть символы цифр с точками "🄀⒈⒉⒊⒋⒌⒍⒎⒏⒐"
Каждая из них это ОДИН СИМВОЛ, поэтому он будет считаться цифрой
>>> '⒌'.isdigit(), '⒌'.isnumeric()
True, True
Но когда мы пишем это выражение в два символа ( 5+точка), то это не работает.
>>> '5.'.isdigit(), '5.'.isnumeric()
False, False
А еще есть такие символы
>>> '⑴⑵⑶⑷⑸'.isdigit()
True
>>> '🄁🄂🄃'.isdigit()
True
Но они не преобразуются в десятичные цифры
>>> '⒈'.isdecimal()
False
>>> '🄃'.isdecimal()
False
>>> '⑶'.isdecimal()
False
#basic
#HappyEaster from all of us at the Nigeria Centre for Disease Control and Prevention.
May this day fill you and your loved ones with joy, happiness, and renewed health.
Let's celebrate the gift of hope and good health as we strive towards healthy living.
The Nigeria Centre for Disease Control and Prevention (NCDC) wishes you a joyful and peaceful Easter. ✝️
As we celebrate this season of hope, renewal, and new beginnings, we are reminded of the importance of protecting our health and the wellbeing of those around us.
While you spend time with loved ones, remember to practice good hygiene, stay informed, and make choices that keep our communities safe.✅
May this Easter bring you renewed strength, happiness, and good health.
Stay safe, stay informed, and enjoy the season. 🌿
#HappyEaster#StayHealthy#NCDCNigeria