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

Резултати

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

Пребарај: #alwaysready

当前筛选 #alwaysready清除筛选
AI match predictions

@ai_match_prediction · Post #12093 · 14.05.2026 г., 13:05

Bolivia Primera División🇧🇴 2026-05-14 19:00 UTC Always Ready vs. The Strongest Predicted outcome: Always Ready❌ Predicted score: 2:1 Actual: The Strongest 0:1 #AlwaysReady#TheStrongest 2026-05-15 00:00 UTC Oriente Petrolero vs. Guabirá Predicted outcome: Oriente Petrolero❌ Predicted score: 3:1 Actual: Draw 2:2 #OrientePetrolero#Guabirá #Football#BoliviaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #12031 · 10.05.2026 г., 13:05

Bolivia Primera División🇧🇴 2026-05-10 19:00 UTC Independiente Petrolero vs. Always Ready Predicted outcome: Always Ready❌ Predicted score: 1:2 Actual: Draw 0:0 #IndependientePetrolero#AlwaysReady 2026-05-10 21:15 UTC The Strongest vs. Real Potosí Predicted outcome: The Strongest❌ Predicted score: 2:1 Actual: Draw 0:0 #TheStrongest#RealPotos 2026-05-10 23:30 UTC Blooming vs. Bolívar Predicted outcome: Bolívar❌ Predicted score: 2:3 Actual: Draw 0:0 #Blooming#Bolvar #Football#BoliviaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11444 · 11.04.2026 г., 13:05

Bolivia Primera División🇧🇴 2026-04-11 19:00 UTC ABB vs. Bolívar Predicted outcome: Bolívar✅ Predicted score: 1:3 Actual: Bolívar 0:2 #ABB#Bolvar 2026-04-11 21:15 UTC Nacional Potosí vs. Universitario de Vinto Predicted outcome: Nacional Potosí✅ Predicted score: 2:0 Actual: Nacional Potosí 1:0 #NacionalPotos#UniversitariodeVinto 2026-04-11 23:30 UTC Aurora vs. Always Ready Predicted outcome: Always Ready❌ Predicted score: 1:3 Actual: Draw 1:1 #Aurora#AlwaysReady #Football#BoliviaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11667 · 22.04.2026 г., 13:05

Bolivia Primera División🇧🇴 2026-04-22 19:00 UTC Always Ready vs. Oriente Petrolero Predicted outcome: Always Ready✅ Predicted score: 4:0 Actual: Always Ready 1:0 #AlwaysReady#OrientePetrolero 2026-04-22 22:00 UTC Real Potosí vs. Guabirá Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Real Potosí 3:0 #RealPotos#Guabirá 2026-04-23 00:00 UTC Blooming vs. Nacional Potosí Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Blooming 2:1 #Blooming#NacionalPotos #Football#BoliviaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11865 · 02.05.2026 г., 13:05

Bolivia Primera División🇧🇴 2026-05-02 19:00 UTC Always Ready vs. Nacional Potosí Predicted outcome: Always Ready✅ Predicted score: 2:1 Actual: Always Ready 3:1 #AlwaysReady#NacionalPotos 2026-05-02 21:15 UTC Aurora vs. Guabirá Predicted outcome: Aurora✅ Predicted score: 3:1 Actual: Aurora 4:2 #Aurora#Guabirá 2026-05-02 23:30 UTC Oriente Petrolero vs. Real Tomayapo Predicted outcome: Oriente Petrolero✅ Predicted score: 3:1 Actual: Oriente Petrolero 3:1 #OrientePetrolero#RealTomayapo #Football#BoliviaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11739 · 25.04.2026 г., 13:05

Bolivia Primera División🇧🇴 2026-04-25 19:00 UTC Nacional Potosí vs. Gualberto Villarroel SJ Predicted outcome: Nacional Potosí❌ Predicted score: 2:1 Actual: Draw 1:1 #NacionalPotos#GualbertoVillarroelSJ 2026-04-25 21:15 UTC ABB vs. Blooming Predicted outcome: Draw❌ Predicted score: 2:2 Actual: ABB 3:2 #ABB#Blooming 2026-04-25 23:30 UTC Guabirá vs. Always Ready Predicted outcome: Always Ready✅ Predicted score: 2:3 Actual: Always Ready 1:2 #Guabirá#AlwaysReady #Football#BoliviaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11295 · 04.04.2026 г., 13:05

Bolivia Primera División🇧🇴 2026-04-04 19:00 UTC Always Ready vs. Real Tomayapo Predicted outcome: Always Ready✅ Predicted score: 3:1 Actual: Always Ready 4:0 #AlwaysReady#RealTomayapo 2026-04-04 21:15 UTC Real Potosí vs. Aurora Predicted outcome: Real Potosí❌ Predicted score: 2:1 Actual: Draw 0:0 #RealPotos#Aurora 2026-04-04 23:30 UTC San Antonio Bulo Bulo vs. Oriente Petrolero Predicted outcome: San Antonio Bulo Bulo✅ Predicted score: 3:1 Actual: San Antonio Bulo Bulo 2:0 #SanAntonioBuloBulo#OrientePetrolero #Football#BoliviaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11530 · 16.04.2026 г., 17:05

CONMEBOL Libertadores🌎 2026-04-16 22:00 UTC Palmeiras vs. Sporting Cristal Predicted outcome: Palmeiras✅ Predicted score: 4:1 Actual: Palmeiras 2:1 #Palmeiras#SportingCristal 2026-04-16 22:00 UTC Lanus vs. Always Ready Predicted outcome: Draw❌ Predicted score: 0:0 Actual: Lanus 1:0 #Lanus#AlwaysReady 2026-04-17 00:30 UTC Flamengo vs. Independiente Medellin Predicted outcome: Flamengo✅ Predicted score: 1:0 Actual: Flamengo 4:1 #Flamengo#IndependienteMedellin 2026-04-17 00:30 UTC Penarol vs. Platense Predicted outcome: Penarol❌ Predicted score: 2:1 Actual: Platense 1:2 #Penarol#Platense #Football#CopaLibertadores

AI match predictions

@ai_match_prediction · Post #11935 · 05.05.2026 г., 17:05

CONMEBOL Libertadores🌎 2026-05-05 22:00 UTC Rosario Central vs. Libertad Asuncion Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Rosario Central 1:0 #RosarioCentral#LibertadAsuncion 2026-05-05 22:00 UTC Sporting Cristal vs. Palmeiras Predicted outcome: Palmeiras✅ Predicted score: 1:2 Actual: Palmeiras 0:2 #SportingCristal#Palmeiras 2026-05-06 00:00 UTC Barcelona SC vs. Boca Juniors Predicted outcome: Boca Juniors❌ Predicted score: 0:1 Actual: Barcelona SC 1:0 #BarcelonaSC#BocaJuniors 2026-05-06 00:00 UTC UCV vs. Independiente del Valle Predicted outcome: Independiente del Valle❌ Predicted score: 2:4 Actual: UCV 2:0 #UCV#IndependientedelValle 2026-05-06 00:30 UTC Always Ready vs. Lanus Predicted outcome: Lanus❌ Predicted score: 0:1 Actual: Always Ready 4:0 #AlwaysReady#Lanus #Football#CopaLibertadores

AI match predictions

@ai_match_prediction · Post #11367 · 07.04.2026 г., 17:05

CONMEBOL Libertadores🌎 2026-04-07 22:00 UTC Independ. Rivadavia vs. Bolívar Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Independ. Rivadavia 1:0 #IndependienteRivadavia#Bolvar 2026-04-07 22:00 UTC Deportivo La Guaira vs. Fluminense Predicted outcome: Fluminense❌ Predicted score: 1:2 Actual: Draw 0:0 #DeportivoLaGuaira#Fluminense 2026-04-08 00:00 UTC Barcelona SC vs. Cruzeiro Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Cruzeiro 0:1 #BarcelonaSC#Cruzeiro 2026-04-08 00:00 UTC Always Ready vs. LDU de Quito Predicted outcome: LDU de Quito✅ Predicted score: 0:1 Actual: LDU de Quito 0:1 #AlwaysReady#LDUdeQuito 2026-04-08 00:30 UTC U. Catolica vs. Boca Juniors Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Boca Juniors 1:2 #UCatolica#BocaJuniors 2026-04-08 02:00 UTC Deportes Tolima vs. Universitario Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 0:0 #DeportesTolima#Universitario #Football#CopaLibertadores

AI match predictions

@ai_match_prediction · Post #11814 · 29.04.2026 г., 17:05

CONMEBOL Libertadores🌎 2026-04-29 22:00 UTC Platense vs. Santa Fe Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Platense 2:1 #Platense#SantaFe 2026-04-29 22:00 UTC Mirassol vs. Always Ready Predicted outcome: Mirassol✅ Predicted score: 2:1 Actual: Mirassol 2:0 #Mirassol#AlwaysReady 2026-04-30 00:00 UTC Barcelona SC vs. U. Catolica Predicted outcome: Barcelona SC❌ Predicted score: 2:1 Actual: U. Catolica 1:2 #BarcelonaSC#UCatolica 2026-04-30 00:30 UTC Estudiantes L.P. vs. Flamengo Predicted outcome: Flamengo❌ Predicted score: 1:2 Actual: Draw 1:1 #EstudiantesLP#Flamengo 2026-04-30 00:30 UTC Cerro Porteno vs. Palmeiras Predicted outcome: Palmeiras❌ Predicted score: 1:2 Actual: Draw 1:1 #CerroPorteno#Palmeiras 2026-04-30 02:00 UTC Universitario vs. Club Nacional Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Universitario 4:2 #Universitario#ClubNacional #Football#CopaLibertadores