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 слични објави

Пребарај: #panathinaikos

当前筛选 #panathinaikos清除筛选
🏆 Info 288 - DEPORTES

@info288_deportes · Post #35614 · 17.10.2024 г., 21:22

🏀🇪🇺Euroliga Real Madrid 90-86 Panathinaikos#Euroliga#RealMadrid#Panathinaikos Para ganar al campeón de la Euroliga hay que hacer un partido muy serio, con mucha concentración, sin demasiados errores... Todo eso lo cumplió el Real Madrid para sacar la cabeza del hoyo en el que estaba (balance de 4-5 ahora en encuentros oficiales) y levantar la voz. Tumbó al Panathinaikos (90-86) en la reedición de la final de la temporada pasada en un triunfo coral que apuntaba a cómodo (78-62, min. 33) y acabó complicándose. En cualquier caso, una inyección de moral. https://www.marca.com/baloncesto/euroliga/2024/10/17/real-madrid-levanta-voz.html Otros marcadores Alba 71-78 Fenerbahce Maccabi 79-91 Partizan Milano 82-85 Zalgiris Bayern 109-107 Paris 🏆@Info288_deportes

AI match predictions

@ai_match_prediction · Post #11607 · 19.04.2026 г., 09:05

Greece Super League 1🇬🇷 2026-04-19 15:00 UTC AEK Athens FC vs. PAOK Predicted outcome: Draw❌ Predicted score: 1:1 Actual: AEK Athens FC 3:0 #AEK#PAOK 2026-04-19 18:00 UTC Panathinaikos vs. Olympiakos Piraeus Predicted outcome: Olympiakos Piraeus✅ Predicted score: 0:1 Actual: Olympiakos Piraeus 0:2 #Panathinaikos#Olympiakos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #12077 · 13.05.2026 г., 09:05

Greece Super League 1🇬🇷 2026-05-13 14:00 UTC Levadiakos vs. OFI Predicted outcome: Levadiakos✅ Predicted score: 3:1 Actual: Levadiakos 3:2 #Levadiakos#OFI 2026-05-13 14:00 UTC Volos NFC vs. Aris Thessalonikis Predicted outcome: Aris Thessalonikis✅ Predicted score: 1:2 Actual: Aris Thessalonikis 1:2 #Volos#Aris 2026-05-13 16:30 UTC Olympiakos Piraeus vs. Panathinaikos Predicted outcome: Olympiakos Piraeus✅ Predicted score: 2:1 Actual: Olympiakos Piraeus 1:0 #Olympiakos#Panathinaikos 2026-05-13 16:30 UTC PAOK vs. AEK Athens FC Predicted outcome: AEK Athens FC❌ Predicted score: 1:2 Actual: Draw 1:1 #PAOK#AEK #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #12023 · 10.05.2026 г., 09:05

Greece Super League 1🇬🇷 2026-05-10 14:00 UTC Aris Thessalonikis vs. OFI Predicted outcome: Aris Thessalonikis✅ Predicted score: 2:1 Actual: Aris Thessalonikis 3:1 #Aris#OFI 2026-05-10 14:00 UTC Volos NFC vs. Levadiakos Predicted outcome: Levadiakos✅ Predicted score: 1:2 Actual: Levadiakos 0:3 #Volos#Levadiakos 2026-05-10 16:30 UTC Olympiakos Piraeus vs. PAOK Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #Olympiakos#PAOK 2026-05-10 16:30 UTC AEK Athens FC vs. Panathinaikos Predicted outcome: AEK Athens FC✅ Predicted score: 2:1 Actual: AEK Athens FC 2:1 #AEK#Panathinaikos #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11894 · 03.05.2026 г., 09:06

Greece Super League 1🇬🇷 2026-05-03 14:00 UTC Levadiakos vs. Volos NFC Predicted outcome: Levadiakos✅ Predicted score: 3:1 Actual: Levadiakos 5:2 #Levadiakos#Volos 2026-05-03 14:00 UTC OFI vs. Aris Thessalonikis Predicted outcome: OFI❌ Predicted score: 2:1 Actual: Aris Thessalonikis 0:2 #OFI#Aris 2026-05-03 16:00 UTC PAOK vs. Olympiakos Piraeus Predicted outcome: Olympiakos Piraeus❌ Predicted score: 1:2 Actual: PAOK 3:1 #PAOK#Olympiakos 2026-05-03 18:00 UTC Panathinaikos vs. AEK Athens FC Predicted outcome: AEK Athens FC❌ Predicted score: 1:2 Actual: Draw 0:0 #Panathinaikos#AEK #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11323 · 05.04.2026 г., 09:05

Greece Super League 1🇬🇷 2026-04-05 14:00 UTC Levadiakos vs. Aris Thessalonikis Predicted outcome: Levadiakos❌ Predicted score: 2:1 Actual: Draw 1:1 #Levadiakos#Aris 2026-04-05 14:00 UTC Volos NFC vs. OFI Predicted outcome: Draw✅ Predicted score: 2:2 Actual: Draw 1:1 #Volos#OFI 2026-04-05 16:00 UTC PAOK vs. Panathinaikos Predicted outcome: PAOK❌ Predicted score: 2:1 Actual: Draw 0:0 #PAOK#Panathinaikos 2026-04-05 18:00 UTC Olympiakos Piraeus vs. AEK Athens FC Predicted outcome: Draw❌ Predicted score: 1:1 Actual: AEK Athens FC 0:1 #Olympiakos#AEK #Football#GreeceSuperLeague1

AI match predictions

@ai_match_prediction · Post #11156 · 22.03.2026 г., 09:06

Greece Super League 1🇬🇷 2026-03-22 17:00 UTC Olympiakos Piraeus vs. Larisa Predicted outcome: Olympiakos Piraeus❌ Predicted score: 2:0 Actual: Draw 0:0 #Olympiakos#Larisa 2026-03-22 17:00 UTC AEK Athens FC vs. Kifisia Predicted outcome: AEK Athens FC✅ Predicted score: 3:1 Actual: AEK Athens FC 3:0 #AEK#Kifisia 2026-03-22 17:00 UTC Panetolikos vs. Panserraikos Predicted outcome: Panetolikos❌ Predicted score: 2:1 Actual: Draw 0:0 #Panetolikos#Panserraikos 2026-03-22 17:00 UTC Asteras Tripolis vs. Panathinaikos Predicted outcome: Panathinaikos✅ Predicted score: 1:2 Actual: Panathinaikos 1:2 #Asteras#Panathinaikos 2026-03-22 17:00 UTC Levadiakos vs. Atromitos Predicted outcome: Levadiakos✅ Predicted score: 2:1 Actual: Levadiakos 1:0 #Levadiakos#Atromitos 2026-03-22 17:00 UTC Aris Thessalonikis vs. OFI Predicted outcome: Aris Thessalonikis❌ Predicted score: 1:0 Actual: OFI 0:2 #Aris#OFI 2026-03-22 17:00 UTC Volos NFC vs. PAOK Predicted outcome: PAOK❌ Predicted score: 0:2 Actual: Volos NFC 2:1 #Volos#PAOK #Football#GreeceSuperLeague1