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

Резултати

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

Пребарај: #vapodcast

当前筛选 #vapodcast清除筛选
Venezuelanalysis

@venanalysis · Post #1569 · 17.05.2024 г., 22:26

🎙We're hosting a first live Q&A on spaces in a couple of days! It’s set for next Monday at 6 ET. Set your reminders and reply here with your questions 👉🏽https://x.com/venanalysis/status/1791586519398171078?s=46&t=XS9Dg5c2R2mjKeBd5qmeTQ #VAPodcast

Hashtags

Venezuelanalysis

@venanalysis · Post #1562 · 14.05.2024 г., 21:44

Join us for our upcoming Q&A Space on X! An open forum for discussing VA Podcast Episode 24, 'Building Socialism to Resist Sanctions.' It's happening next Thursday, May 16th. 🔔 Click here to set a reminder 👉🏽https://twitter.com/i/spaces/1YqKDgnodVNxV #VAPodcast#Sanctions

Venezuelanalysis

@venanalysis · Post #1644 · 10.07.2024 г., 19:26

🎙 A special episode of the Venezuelanalysis Podcast is now available! VA members José Luis Granados Ceja and Andreína Chávez Alava discuss soft power, cultural imperialism and corporate media propaganda ahead of Venezuela's presidential elections. Click here to listen to the full episode 👉🏼shorturl.at/FkBrG #presidentialelections2024#vapodcast

Venezuelanalysis

@venanalysis · Post #1747 · 18.09.2024 г., 19:38

🎙 Episode 26 of the Venezuelanalysis Podcast is here! Host José Luis Granados Ceja is joined by editor Ricardo Vaz to break down the electoral aftermath in Venezuela, covering renewed U.S. sanctions, Edmundo González's exile, aircraft piracy, and more. After a brief hiatus, we’re back with a new format—featuring VA staff more prominently and, for the first time, available on video! Click here to listen and watch the full episode 👉🏼https://shorturl.at/ivof8 #vapodcast#presidentialelections2024#sanctions

Venezuelanalysis

@venanalysis · Post #1523 · 03.04.2024 г., 23:02

🎙New podcast episode just dropped! In our latest podcast episode, we tackle cultural production, its importance and challenges in the context of the Bolivarian Process. Host José Luis Granados Ceja is joined by activist and culture worker Luigino Bracci Roa and by fellow VA member Andreína Chávez Alava to discuss everything from state policies to imperialist propaganda. Click here to listen to the full episode 👉🏼https://shorturl.at/hrCHN #culture#vapodcast

Venezuelanalysis

@venanalysis · Post #2322 · 31.03.2026 г., 01:21

🔈PODCAST | Venezuela After January 3: A New Stage of US Imperialism The VA Podcast is back. In our Season 3 premiere, we tackle the fallout of the January 3rd military escalation against Caracas, an event that marks a volatile new chapter in the long history of US intervention in the region. Join Venezuelanalysis Chief Editor Ricardo Vaz, Associate Editor Lucas Koerner, and VA Founder Greg Wilpert as they break down the geopolitical shift from "maximum pressure" to direct confrontation. This episode goes beyond the headlines to analyze the underlying causes and the global consequences of Washington’s renewed focus on "its" hemisphere. Follow the link for early access to this episode: https://www.patreon.com/venanalysis #USVenezuelaRelations#USmilitaryattack#VAPodcast

Venezuelanalysis

@venanalysis · Post #2320 · 29.03.2026 г., 00:25

🎙🔊Season 3 of the Venezuelanalysis Podcast is coming soon!!! The new season takes stock of a shifting political moment marked by escalating US aggression and its global impact, alongside major developments inside Venezuela: from the January 3 US military strikes to international solidarity efforts, as well as broader economic reforms and debates over sovereignty and national control of resources. Each month, we will bring independent, on-the-ground reporting and analysis of Venezuela and the Bolivarian Process, alongside coverage of grassroots movements. 🎧 Subscribe to the Venezuelanalysis Podcast on YouTube, Spotify, Apple Podcasts, or your preferred platform. #podcast#VAPodcast#USVenezuelaRelations

Venezuelanalysis

@venanalysis · Post #1587 · 29.05.2024 г., 22:11

🎙 Episode 25 of the Venezuelanalysis Podcast is now available! Venezuela’s revolutionary leader Hugo Chávez defined the commune as the “unit cell” for the construction of socialism. But the road ahead is full of challenges, even more so in a context of imperialist sanctions. In this episode, host José Luis Granados Ceja is joined by fellow VA member Cira Pascual Marquina and by Communard Union communications coordinator Juan Lenzo to discuss the present struggle to strengthen the communal economy and uphold the socialist horizon. Click here to listen to the full episode 👉🏼https://shorturl.at/gf26s #communardunion#communes#vapodcast

Venezuelanalysis

@venanalysis · Post #1837 · 19.12.2024 г., 21:26

🎙 Last VA Podcast of 2024 is live! In our yearly review, the Venezuelanaysis editorial team examines Venezuela's economic challenges, grassroots efforts, and the aftermath of the 2024 presidential election. We also discuss what 2025 might bring for the country and the Bolivarian Process. Watch now 👉🏼https://youtu.be/p3gzIhkykuc #VAPodcast#2024Recap

Venezuelanalysis

@venanalysis · Post #1782 · 23.10.2024 г., 13:28

A crowdfunded mercenary plot? 🤔 Venezuelanalysis members José Luis Granados Ceja and Ricardo Vaz have a little fun at the expense of a crowdfunding initiative for a coup led by mercenary poster boy Erik Prince. Watch the full podcast episode here 👉🏼youtu.be/hD4Ds9Xc1ho #vapodcast#sanctions#imperialism#citgo

Venezuelanalysis

@venanalysis · Post #2324 · 01.04.2026 г., 22:38

🎙🔊 Episode 43 of the VA Podcast is live! The Venezuelanalysis Podcast is back. In our new season premiere, we tackle the fallout of the January 3rd military escalation against Caracas, an event that marks a volatile new chapter in the long history of US intervention in the region. Join Venezuelanalysis Lead Editor Ricardo Vaz, Associate Editor Lucas Koerner, and VA Founder Greg Wilpert as they break down the geopolitical shift from "maximum pressure" to direct confrontation. This episode goes beyond the headlines to analyze the underlying causes and the global consequences of Washington’s renewed focus on "its" hemisphere. Watch the full episode here 👉https://youtu.be/NKuCNIxn2MA #Venezuela#USImperialism#usvenezuelarelations#USmilitaryattack#VAPodcast

Venezuelanalysis

@venanalysis · Post #2374 · 19.05.2026 г., 00:28

🔈PODCAST | International Solidarity in the Belly of the Beast [EARLY ACCESS] What does meaningful international solidarity with Venezuela look like from inside the US empire? In Episode 45 of the Venezuelanalysis podcast, Ricardo Vaz speaks with Austin Cole of the Black Alliance for Peace and Michela Martinazzi of Brooklyn Against War and the International League of Peoples’ Struggle about organizing against imperialism from “the belly of the beast.” The conversation looks at escalating attacks abroad, repression at home, the challenges facing solidarity movements, and how to build broad coalitions without falling into the bipartisan trap. Get early access to the episode and support independent anti-imperialist journalism 👉🏽patreon.com/c/venanalysis #InternationalSolidarity#AntiImperialism#Podcast#VAPodcast

12
ПретходнаСтраница 1 од 2Следна