TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #83 · 11 мај

У строки в Python есть два очень похожих метода. На столько похожих что кажется они делают одно и тоже. Это метод isdigit() и isnumeric() Давайте посмотрим зачем нам два одинаковых метода? И так ли они одинаковы? Очевидно что isdigit() говорит нам, состоит ли строка только из чисел 0-9 >>> '12'.isdigit() True >>> '12x'.isdigit() False >>> '-12'.isdigit() False >>> '12.5'.isdigit() False Можно предположить что isnumeric() делает более глубокий анализ и распознаёт в строке float или отрицательное число. >>> '15'.isnumeric() True >>> '-15'.isnumeric() False >>> '15.2'.isnumeric() False Нет, всё так же как и с другим методом. В чем же тогда разница? Для начала посмотрим следующие примеры: >>> '5'.isdigit(), '5'.isnumeric() # Обычная цифра 5 # True, True >>> '꧕'.isdigit(), '꧕'.isnumeric() # Яванская 5 # True, True >>> '෩'.isdigit(), '෩'.isnumeric() # Синхала 3 # True, True >>> '৩'.isdigit(), '৩'.isnumeric() # Бенгальская 3 # True, True >>> '༣'.isdigit(), '༣'.isnumeric() # Тибетская 3 # True, True >>> '³'.isdigit(), '³'.isnumeric() # 3 верхний индекс (степень) # True, True >>> '𝟝'.isdigit(), '𝟝'.isnumeric() # Математическая двойная 5 # True, True >>> '๔'.isdigit(), '๔'.isnumeric() # Тайская 4 # True, True >>> '➑'.isdigit(), '➑'.isnumeric() # 8 в круге # True, True А теперь примеры в которых, по мнению Python, результаты не равны >>> '¾'.isdigit(), '¾'.isnumeric() # дробь три четверти # False, True >>> '⅕'.isdigit(), '⅕'.isnumeric() # дробь одна пятая # False, True >>> '𒐶'.isdigit(), '𒐶'.isnumeric() # клинопись 3 # False, True >>> '三'.isdigit(), '三'.isnumeric() # 3 из унифицированной идеограммы # False, True >>> '⑩'.isdigit(), '⑩'.isnumeric() # цифра 10 в круге # False, True >>> 'Ⅳ'.isdigit(), 'Ⅳ'.isnumeric() # Римская 4 # False, True >>> '𑇪'.isdigit(), '𑇪'.isnumeric() # Сенегальская архаическая 10 # False, True >>> '𐌢'.isdigit(), '𐌢'.isnumeric() # Этрусская цифра 10 # False, True >>> 'ↂ'.isdigit(), 'ↂ'.isnumeric() # Римская цифра 10000 # False, True >>> '〇'.isdigit(), '〇'.isnumeric() # Символ ККЯ ноль # False, True Получается, что isdigit() говорит нам, является ли символ десятичной цифрой или спецсимволом, имеющим цифирное значение после преобразования. В свою очередь isnumeric() включает все дополнительные символы юникода которые имеют отношения к числовым и цифровым представлениям. Ну и пара примеров в которых в обоих случаях символ не является числом, это эмодзи. >>> '🕙'.isdigit(), '🕙'.isnumeric() # эмодзи 10 часов # False, False >>> '7️⃣'.isdigit(), '7️⃣'.isnumeric() # эмодзи 7 # False, False Также есть еще один дополнительный и весьма полезный метод isdecimal(). Он нам сообщает, можно ли из указанного символа сделать простую десятичную цифру. То есть сработает ли метод int(x) >>> '෩'.isdecimal(), int('෩') # Синхала 3 # True, 3 >>> '➑'.isdecimal(), int('➑') # 8 в круге # False, ValueError Какие выводы? 🔸 При определении цифры в строке isdigit() подходит лучше чем isnumeric(), но оба не гарантируют успешную конвертацию в int 🔸 Для однозначного определения возможности преобразования строки в int лучше подходит метод isdecimal() 🔸 Для однозначного определения символов 0...9 лучше использовать regex Полный список символов юникода которые определяются как numeric #basic

Hashtags

Резултати

Пронајдени 4 слични објави

Пребарај: #truthmatters

当前筛选 #truthmatters清除筛选

@RusEmbMalta: 🇷🇺 3 ноября 2025 г. опубликован комментарий Посла России на Мальте А.Г.Лопухова на редакционную статью Times of Malta от 19 октября 2025 г. 📰 В своём комментарии А.Г.Лопухов подчеркнул необходимость опираться на проверенные факты при оценке событий на Украине и предостерёг от распространения дезинформации. Основные тезисы: 🔹 так называемый «украинский кризис» начался не в феврале 2022 г., а с госпереворота в Киеве в 2014 г.; 🔹 киевские власти годами проводили политику дискриминации и насилия в отношении русскоязычного населения; 🔹 трагедия в Одессе в мае 2014 г. остаётся нераскрытым преступлением; 🔹 поставки оружия Киеву и финансовая поддержка со стороны Запада лишь усугубляют кризис; 🔹 Россия на протяжении лет последовательно поднимала вопрос о массовых нарушениях прав человека, несмотря на нежелание Запада слышать правду; 🔹 миллионы людей во всём мире поверили России, потому что правда, как бы её ни пытались скрыть, всегда пробивается сквозь ложь. 💬«Есть факты, которые невозможно опровергнуть. И именно они заставили людей по всему миру увидеть происходящее своими глазами и сделать собственные выводы.» 🔗 Полный текст комментария на сайте Times of Malta. #КризисНаУкраине#TruthMatters

@RusEmbMalta: On November 3, 2025, the Times of Malta published a commentary by the Russian Ambassador to Malta, Andrey Lopukhov, responding to the editorial of October 19, 2025 📰 In his commentary, Ambassador Lopukhov emphasized the importance of relying on verified facts when assessing the situation in Ukraine and warned against the spread of misinformation. Key points: 🔹 the so-called “Ukrainian crisis” began not in February 2022, but with the coup d’état in Kiev in 2014; 🔹 for years, the Kiev authorities pursued policies of discrimination and violence against Russian-speaking citizens; 🔹 the Odessa tragedy of May 2014 remains an uninvestigated crime; 🔹 Western arms supplies and financial support to Kiev only deepen the crisis; 🔹 Russia has consistently raised the issue of human-rights violations by the Kiev regime, despite the West’s unwillingness to listen; 🔹 millions of people around the world believed Russia – because truth, however suppressed, always breaks through lies and propaganda. 💬“There are facts that cannot be denied. And it is those very facts that made people across the world see what was happening with their own eyes and draw their own conclusions.” 🔗 Read the full text of the commentary onTimes of Malta. #UkrainianCrisis#TruthOnUkraine#TruthMatters

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3487 · 19.10.2024 г., 03:44

In times like these, when reporting news has become a tool in the hands of empire, brainwashing people into accepting genocide under the false pretext of a "right to self-defense" for occupying powers against native populations, we must remember the truth-tellers. As occupation forces target journalists in #Gaza with sniper fire and bomb journalists in Lebanon, we are reminded of the courage of those who dared to expose the lies. Today, we remember @PressTV 's Serena Shim, a Lebanese-American journalist, who passed on October 19, 2014, in least to say mysterious circumstances. Serena had uncovered and reported a truth that many wanted buried: the smuggling of Al-Qaeda terrorists from Turkey to Syria, hidden on WHO trucks, to bring devastation to a nation. Her work highlighted how the powerful manipulate narratives and use humanitarian fronts to cloak their actions. Serena's bravery stands in stark contrast to the silence of many today. At a time when the powerful seek to erase voices and twist facts, let us honor her memory by sharing the stories that the empire wants to suppress. Let us remember that truth is the first casualty of war—and that we must keep it alive, for Serena, for the journalists under fire, and for all who suffer in silence. #RememberSerenaShim#TruthMatters#StopGenocideNow #SerenaShim

HHS Rapid Response

@HHSResponse · Post #4 · 29.10.2025 г., 20:59

🔹🔷Welcome to the Official HHS Rapid Response Channel 🔷🔹 This is the official @HHSgovv Rapid Response account, working every day to support President Trump’s and Secretary Kennedy’s mission to Make America Healthy Again (MAHA). 🇺🇸 Here, we deliver real facts, rapid updates, and clear information to cut through misinformation and ensure the American people get the truth they deserve. Health is strength. Truth is power. Together, we will Make America Healthy Again.💪 Stay tuned for verified updates, fact checks, and official responses from the U.S. Department of Health and Human Services. #RapidResponse | #MAHA | #HHS | #PublicHealth | #TruthMatters 📱https://t.me/HHSResponse✅️