В продолжение прошлого поста про цифры в мире строк.
Почему методы 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
🐍During this festive season of the #LunarNewYear, the entire CyberCharge team wishes you a Happy Year of the Snake!
May this year bring prosperity and joy to you and your loved ones 🫂
Thank you for your continued support, helping us grow and achieve incredible milestones.
We're just getting started! 🚀
🤖Earn NOW📱X(Twitter) 📱Chat💬Discord📱YouTube
Dear friends,
Warm greetings on the occasion of #LunarNewYear!
We wish you good health, happiness and prosperity! May this upcoming year bring along success and great fortune for you and your families.
Sincerely yours,
Russian Mission to #ASEAN
Bringing good luck and prosperity into the new year with the power of red! From lanterns 🏮 to envelopes 🧧, red is a traditional color of #ChineseNewYear. Don't forget to add a touch of red to your celebrations for a prosperous.
Принося удачу и процветание в новый год силой красного! От фонарей до конвертов, красный является традиционным цветом #ChineseNewYear. Не забудьте добавить нотку красного к своим празднованиям для процветающего.
#LunarNewYear#wallpaper
🧧 Follow 🧧@PeachLovesGoma🧧
Wish everyone a happy Lunar New Year! Bring glory back to Hong Kong in the year of dragon!
#HKDMovement
#glorytoHongKong
#lunarnewyear
#standwithhongkong