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

Резултати

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

Пребарај: #ucv

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

@ai_match_prediction · Post #12069 · 12.05.2026 г., 17:05

Venezuela Primera División🇻🇪 2026-05-12 22:00 UTC Deportivo Tachira FC vs. Metropolitanos FC Predicted outcome: Deportivo Tachira FC❌ Predicted score: 2:1 Actual: Draw 1:1 #DeportivoTachiraFC#MetropolitanosFC 2026-05-12 23:30 UTC UCV vs. Deportivo La Guaira Predicted outcome: Deportivo La Guaira❌ Predicted score: 1:2 Actual: Draw 1:1 #UCV#DeportivoLaGuaira #Football#VenezuelaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11263 · 03.04.2026 г., 17:06

Venezuela Primera División🇻🇪 2026-04-03 21:30 UTC Academia Anzoátegui vs. UCV Predicted outcome: UCV✅ Predicted score: 1:3 Actual: UCV 2:3 #AcademiaAnzoátegui#UCV 2026-04-03 23:30 UTC Caracas FC vs. Metropolitanos FC Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Caracas FC 1:0 #CaracasFC#MetropolitanosFC #Football#VenezuelaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11612 · 19.04.2026 г., 13:05

Venezuela Primera División🇻🇪 2026-04-19 21:00 UTC Estudiantes de Merida FC vs. Monagas SC Predicted outcome: Estudiantes de Merida FC✅ Predicted score: 2:1 Actual: Estudiantes de Merida FC 3:2 #EstudiantesdeMeridaFC#MonagasSC 2026-04-19 23:00 UTC UCV vs. Deportivo Tachira FC Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #UCV#DeportivoTachiraFC #Football#VenezuelaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11996 · 09.05.2026 г., 13:05

Venezuela Primera División🇻🇪 2026-05-09 20:00 UTC Deportivo La Guaira vs. Portuguesa FC Predicted outcome: Deportivo La Guaira❌ Predicted score: 2:1 Actual: Draw 1:1 #DeportivoLaGuaira#PortuguesaFC 2026-05-10 00:00 UTC UCV vs. Puerto Cabello Predicted outcome: UCV✅ Predicted score: 2:1 Actual: UCV 3:1 #UCV#PuertoCabello 2026-05-10 00:30 UTC Deportivo Tachira FC vs. Carabobo FC Predicted outcome: Deportivo Tachira FC✅ Predicted score: 2:1 Actual: Deportivo Tachira FC 3:1 #DeportivoTachiraFC#CaraboboFC #Football#VenezuelaPrimeraDivisión

AI match predictions

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

Venezuela Primera División🇻🇪 2026-05-02 20:00 UTC Estudiantes de Merida FC vs. Deportivo Tachira FC Predicted outcome: Estudiantes de Merida FC✅ Predicted score: 2:1 Actual: Estudiantes de Merida FC 2:1 #EstudiantesdeMeridaFC#DeportivoTachiraFC 2026-05-02 22:00 UTC Portuguesa FC vs. UCV Predicted outcome: Portuguesa FC❌ Predicted score: 3:2 Actual: Draw 1:1 #PortuguesaFC#UCV 2026-05-03 00:00 UTC Puerto Cabello vs. Deportivo La Guaira Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #PuertoCabello#DeportivoLaGuaira #Football#VenezuelaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11481 · 12.04.2026 г., 13:05

Venezuela Primera División🇻🇪 2026-04-12 21:00 UTC Carabobo FC vs. UCV Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Carabobo FC 4:2 #CaraboboFC#UCV 2026-04-12 21:30 UTC Trujillanos FC vs. Estudiantes de Merida FC Predicted outcome: Estudiantes de Merida FC✅ Predicted score: 1:3 Actual: Estudiantes de Merida FC 0:2 #TrujillanosFC#EstudiantesdeMeridaFC 2026-04-12 23:00 UTC Caracas FC vs. Academia Anzoátegui Predicted outcome: Caracas FC❌ Predicted score: 1:0 Actual: Academia Anzoátegui 1:3 #CaracasFC#AcademiaAnzoátegui #Football#VenezuelaPrimeraDivisión

AI match predictions

@ai_match_prediction · Post #11390 · 09.04.2026 г., 17:05

CONMEBOL Libertadores🌎 2026-04-09 22:00 UTC Rosario Central vs. Independiente del Valle Predicted outcome: Independiente del Valle❌ Predicted score: 1:2 Actual: Draw 0:0 #RosarioCentral#IndependientedelValle 2026-04-09 22:00 UTC UCV vs. Libertad Asuncion Predicted outcome: Draw❌ Predicted score: 1:1 Actual: UCV 3:1 #UCV#LibertadAsuncion 2026-04-10 00:00 UTC Platense vs. Corinthians Predicted outcome: Corinthians✅ Predicted score: 1:2 Actual: Corinthians 0:2 #Platense#Corinthians 2026-04-10 02:00 UTC Santa Fe vs. Penarol Predicted outcome: Penarol❌ Predicted score: 0:1 Actual: Draw 1:1 #SantaFe#Penarol #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 #11522 · 15.04.2026 г., 17:05

CONMEBOL Libertadores🌎 2026-04-15 22:00 UTC Cruzeiro vs. U. Catolica Predicted outcome: Cruzeiro❌ Predicted score: 1:0 Actual: U. Catolica 1:2 #Cruzeiro#UCatolica 2026-04-15 22:00 UTC Libertad Asuncion vs. Rosario Central Predicted outcome: Draw❌ Predicted score: 0:0 Actual: Rosario Central 0:1 #LibertadAsuncion#RosarioCentral 2026-04-16 00:30 UTC Fluminense vs. Independ. Rivadavia Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Independ. Rivadavia 1:2 #Fluminense#IndependienteRivadavia 2026-04-16 00:30 UTC Corinthians vs. Santa Fe Predicted outcome: Corinthians✅ Predicted score: 2:0 Actual: Corinthians 2:0 #Corinthians#SantaFe 2026-04-16 02:00 UTC Independiente del Valle vs. UCV Predicted outcome: UCV❌ Predicted score: 1:2 Actual: Independiente del Valle 3:1 #IndependientedelValle#UCV #Football#CopaLibertadores

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