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

Резултати

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

Пребарај: #zwolle

当前筛选 #zwolle清除筛选
Addis Standard

@addisstandardeng · Post #21218 · 28.01.2026 г., 07:46

#Dutch court sentences #Eritrea human trafficker to 20 years A Dutch court on Tuesday sentenced an Eritrean man to 20 years in prison for operating a human trafficking ring in which migrants were tortured and their families extorted. The court said the man, identified as Amanuel #Walid, had treated migrants "without any humanity" as they were transported from Eritrea to #Europe via #Libya. "Your only aim was to earn as much money as possible from people who were looking for a better future," presiding judge Rene Melaard told Walid. The court in the northern Dutch city of #Zwolle heard how gang members tortured victims while on the phone to their families in the Netherlands, demanding payments to make the abuse stop. Only once family members had transferred money were the victims put on rickety boats for the perilous trip across the Mediterranean Sea. Many drowned in the crossing. https://www.facebook.com/AddisstandardEng/posts/pfbid0e9YqCpyLghyEouyA911hTeebioBPf4mTh4fVeBBchU9xr53T5qZURCXU8qW5ZQisl

AI match predictions

@ai_match_prediction · Post #11677 · 23.04.2026 г., 09:05

Netherlands Eredivisie🇳🇱 2026-04-23 16:45 UTC GO Ahead Eagles vs. AZ Alkmaar Predicted outcome: GO Ahead Eagles❌ Predicted score: 2:1 Actual: Draw 0:0 #GOAheadEagles#AZAlkmaar 2026-04-23 19:00 UTC PSV Eindhoven vs. PEC Zwolle Predicted outcome: PSV Eindhoven✅ Predicted score: 4:1 Actual: PSV Eindhoven 6:1 #PSVEindhoven#Zwolle #Football#Eredivisie

AI match predictions

@ai_match_prediction · Post #11123 · 21.03.2026 г., 09:06

Netherlands Eredivisie🇳🇱 2026-03-21 15:30 UTC Fortuna Sittard vs. Twente Predicted outcome: Twente✅ Predicted score: 1:2 Actual: Twente 1:2 #FortunaSittard#Twente 2026-03-21 17:45 UTC Sparta Rotterdam vs. FC Volendam Predicted outcome: Sparta Rotterdam✅ Predicted score: 1:0 Actual: Sparta Rotterdam 2:0 #SpartaRotterdam#FCVolendam 2026-03-21 20:00 UTC PEC Zwolle vs. NAC Breda Predicted outcome: PEC Zwolle✅ Predicted score: 2:1 Actual: PEC Zwolle 2:1 #Zwolle#Breda #Football#Eredivisie

AI match predictions

@ai_match_prediction · Post #11460 · 12.04.2026 г., 05:05

Netherlands Eredivisie🇳🇱 2026-04-12 10:15 UTC Fortuna Sittard vs. NAC Breda Predicted outcome: Fortuna Sittard❌ Predicted score: 2:1 Actual: Draw 1:1 #FortunaSittard#Breda 2026-04-12 12:30 UTC PEC Zwolle vs. Excelsior Predicted outcome: Draw✅ Predicted score: 2:2 Actual: Draw 2:2 #Zwolle#Excelsior 2026-04-12 12:30 UTC NEC Nijmegen vs. Feyenoord Predicted outcome: NEC Nijmegen❌ Predicted score: 2:1 Actual: Draw 1:1 #NECNijmegen#Feyenoord 2026-04-12 14:45 UTC AZ Alkmaar vs. Heerenveen Predicted outcome: AZ Alkmaar✅ Predicted score: 2:1 Actual: AZ Alkmaar 3:0 #AZAlkmaar#Heerenveen #Football#Eredivisie

AI match predictions

@ai_match_prediction · Post #11879 · 03.05.2026 г., 05:06

Netherlands Eredivisie🇳🇱 2026-05-03 10:15 UTC FC Volendam vs. Heerenveen Predicted outcome: FC Volendam❌ Predicted score: 2:1 Actual: Heerenveen 0:2 #FCVolendam#Heerenveen 2026-05-03 12:30 UTC PEC Zwolle vs. Heracles Predicted outcome: PEC Zwolle✅ Predicted score: 2:1 Actual: PEC Zwolle 1:0 #Zwolle#Heracles 2026-05-03 12:30 UTC Fortuna Sittard vs. Feyenoord Predicted outcome: Feyenoord✅ Predicted score: 1:2 Actual: Feyenoord 1:2 #FortunaSittard#Feyenoord 2026-05-03 14:45 UTC AZ Alkmaar vs. Twente Predicted outcome: Twente❌ Predicted score: 1:2 Actual: Draw 2:2 #AZAlkmaar#Twente 2026-05-03 14:45 UTC Sparta Rotterdam vs. GO Ahead Eagles Predicted outcome: GO Ahead Eagles❌ Predicted score: 1:2 Actual: Draw 2:2 #SpartaRotterdam#GOAheadEagles #Football#Eredivisie

AI match predictions

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

Netherlands Eredivisie🇳🇱 2026-05-10 14:45 UTC Ajax vs. Utrecht Predicted outcome: Ajax❌ Predicted score: 2:1 Actual: Utrecht 1:2 #Ajax#Utrecht 2026-05-10 14:45 UTC Excelsior vs. FC Volendam Predicted outcome: Excelsior❌ Predicted score: 2:1 Actual: Draw 1:1 #Excelsior#FCVolendam 2026-05-10 14:45 UTC Groningen vs. NEC Nijmegen Predicted outcome: NEC Nijmegen❌ Predicted score: 2:3 Actual: Groningen 2:1 #Groningen#NECNijmegen 2026-05-10 14:45 UTC Fortuna Sittard vs. PEC Zwolle Predicted outcome: Fortuna Sittard✅ Predicted score: 2:1 Actual: Fortuna Sittard 3:2 #FortunaSittard#Zwolle 2026-05-10 14:45 UTC Feyenoord vs. AZ Alkmaar Predicted outcome: Feyenoord❌ Predicted score: 2:1 Actual: Draw 1:1 #Feyenoord#AZAlkmaar 2026-05-10 14:45 UTC GO Ahead Eagles vs. PSV Eindhoven Predicted outcome: GO Ahead Eagles❌ Predicted score: 3:2 Actual: PSV Eindhoven 1:4 #GOAheadEagles#PSVEindhoven 2026-05-10 14:45 UTC Twente vs. Sparta Rotterdam Predicted outcome: Twente✅ Predicted score: 2:1 Actual: Twente 4:0 #Twente#SpartaRotterdam 2026-05-10 14:45 UTC Telstar vs. Heracles Predicted outcome: Telstar✅ Predicted score: 3:1 Actual: Telstar 3:0 #Telstar#Heracles 2026-05-11 12:30 UTC NAC Breda vs. Heerenveen Predicted outcome: Heerenveen❌ Predicted score: 1:2 Actual: NAC Breda 2:0 #Breda#Heerenveen #Football#Eredivisie