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

Резултати

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

Пребарај: #womensrights

当前筛选 #womensrights清除筛选
Venezuelanalysis

@venanalysis · Post #1901 · 07.03.2025 г., 17:37

📝 INTERVIEW | Feminism and Revolution: A Conversation with Alejandra Laprea In the latest VA interview, Alejandra Laprea, a popular feminist and member of the World March of Women, discusses how popular feminism in Venezuela continues to shape the revolution from the ground up. She stresses the importance of unity within the feminist movement, advocating for a collective, consensus-based agenda. "We are experiencing a moment of setbacks at the global, continental, and national levels. In Venezuela, the feminist movement must come together and build a common agenda – one that is truly collective and based on consensus, rather than a mere compilation of different perspectives." States Alejandra. 🔗 Read the full interview here: https://shorturl.at/ppCss #Feminism#Sanctions#WomensRights

Venezuelanalysis

@venanalysis · Post #2295 · 08.03.2026 г., 14:45

🗒️🗣️ INTERVIEW | Aimee Zambrano: ‘Let Us Demand a Justice System with a Gender Perspective’ In the latest VA interview, activist and researcher Aimee Zambrano takes stock of gender violence in Venezuela and the necessary state policies to respond. Through the Utopix Femicide Monitor, a platform that collects cases from open sources, Zambrano and her team have tracked patterns since 2019. However, Zambrano warns that other forms of violence are increasing, particularly attempted femicides, sexual abuse, and cases linked to the disappearance of women and girls. She also argues that Venezuela needs a justice system with a gender perspective and a coordinated state response involving multiple ministries, including education, housing, and communication, to address gender violence. Read the full interview here 👉🏾https://shorturl.at/tCbzV #Feminisms#WomensRights

🇿🇦"You Strike a Woman, You Strike a Rock" Today is National Women’s Day in South Africa. 🗓 On August 9, 1956, a protest march was held in Pretoria against the extension of the humiliating Pass Laws to black women — apartheid-era regulations requiring all black South Africans to carry a “dompas” containing their personal details and movement permits. ✊ The march was led by four courageous women: Helen Joseph, Rahima Moosa, Sophie Williams, and Lillian Ngoyi. A monument in central Pretoria now honors their legacy. 📌 The slogan "You strike a woman, you strike a rock" became a powerful emblem of women’s strength and resilience: oppression only solidifies their resolve. #SouthAfrica#NationalWomensDay#PassLaws#Apartheid#Pretoria#WomensRights#History

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40811 · 17.03.2026 г., 07:02

Female genital mutilation (FGM) also misleadingly known as "female circumcision" removes and injures parts of the female genitals for non-medical reasons. It is usually performed on girls from infancy to age 15. It has no health benefits and can cause severe pain, heavy bleeding, infection, shock, infertility, childbirth complications, and psychological trauma. Over 230 million women and girls worldwide have undergone FGM. No religion requires or asks for this practice. 🚫✂️👧🌍⚖🪧 Warning, the link and information about this is not for the faint of heart. Research about this might be disturbing to some people. [Read more at your own discretion] [Poll about your opinions] @googlefactss #facts#humanrights#health#womensrights#education#globalissues#childabuse

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40796 · 14.03.2026 г., 20:05

Mojtaba Khamenei became Supreme Leader of Iran after his father, Ali Khamenei, was killed in a U.S.–Israeli airstrike. He leads with hard-line policies, controlling the military, security forces, and political decisions. For ordinary Iranians, this means strict government control, limited political freedom, limited internet, harsh enforcement of laws, and continued tensions with the West. Daily life and dissent will likely remain tightly restricted under his rule. 🕌🇮🇷⚔️ [Read more] @googlefactss #Iran#MojtabaKhamenei#SupremeLeader#politics#newsfacts#freeIran#protests#womensrights