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

Пребарај: #stmirren

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

@ai_match_prediction · Post #11859 · 02.05.2026 г., 09:06

Scotland Premiership🏴󠁧󠁢󠁳󠁣󠁴󠁿 2026-05-02 14:00 UTC Kilmarnock vs. Dundee Utd Predicted outcome: Dundee Utd❌ Predicted score: 2:3 Actual: Kilmarnock 3:0 #Kilmarnock#DundeeUtd 2026-05-02 14:00 UTC Dundee vs. ST Mirren Predicted outcome: Dundee✅ Predicted score: 2:1 Actual: Dundee 1:0 #Dundee#STMirren 2026-05-02 14:00 UTC Falkirk vs. Motherwell Predicted outcome: Motherwell❌ Predicted score: 1:2 Actual: Falkirk 1:0 #Falkirk#Motherwell #Football#ScotlandPremiership

AI match predictions

@ai_match_prediction · Post #11732 · 25.04.2026 г., 09:06

Scotland Premiership🏴󠁧󠁢󠁳󠁣󠁴󠁿 2026-04-25 14:00 UTC ST Mirren vs. Livingston Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Livingston 0:2 #STMirren#Livingston 2026-04-25 14:00 UTC Aberdeen vs. Kilmarnock Predicted outcome: Aberdeen✅ Predicted score: 2:1 Actual: Aberdeen 1:0 #Aberdeen#Kilmarnock 2026-04-25 16:30 UTC Celtic vs. Falkirk Predicted outcome: Celtic✅ Predicted score: 2:1 Actual: Celtic 3:1 #Celtic#Falkirk #Football#ScotlandPremiership

AI match predictions

@ai_match_prediction · Post #11290 · 04.04.2026 г., 09:07

Scotland Premiership🏴󠁧󠁢󠁳󠁣󠁴󠁿 2026-04-04 14:00 UTC Hibernian vs. Kilmarnock Predicted outcome: Hibernian✅ Predicted score: 2:1 Actual: Hibernian 3:0 #Hibernian#Kilmarnock 2026-04-04 14:00 UTC ST Mirren vs. Aberdeen Predicted outcome: Draw❌ Predicted score: 1:1 Actual: ST Mirren 2:0 #STMirren#Aberdeen 2026-04-04 14:00 UTC Motherwell vs. Falkirk Predicted outcome: Motherwell❌ Predicted score: 1:0 Actual: Falkirk 2:3 #Motherwell#Falkirk 2026-04-04 14:00 UTC Rangers vs. Dundee Utd Predicted outcome: Rangers✅ Predicted score: 3:1 Actual: Rangers 4:2 #Rangers#DundeeUtd #Football#ScotlandPremiership

AI match predictions

@ai_match_prediction · Post #12065 · 12.05.2026 г., 13:05

Scotland Premiership🏴󠁧󠁢󠁳󠁣󠁴󠁿 2026-05-12 18:45 UTC Kilmarnock vs. Dundee Predicted outcome: Kilmarnock✅ Predicted score: 2:1 Actual: Kilmarnock 3:1 #Kilmarnock#Dundee 2026-05-12 18:45 UTC Aberdeen vs. ST Mirren Predicted outcome: Aberdeen❌ Predicted score: 2:1 Actual: ST Mirren 0:2 #Aberdeen#STMirren 2026-05-12 18:45 UTC Dundee Utd vs. Livingston Predicted outcome: Dundee Utd❌ Predicted score: 2:1 Actual: Draw 0:0 #DundeeUtd#Livingston 2026-05-12 18:45 UTC Dunfermline vs. Partick Predicted outcome: Dunfermline❌ Predicted score: 2:1 Actual: Draw 1:1 #Dunfermline#Partick #Football#ScotlandPremiership

AI match predictions

@ai_match_prediction · Post #11988 · 09.05.2026 г., 09:06

Scotland Premiership🏴󠁧󠁢󠁳󠁣󠁴󠁿 2026-05-09 14:00 UTC ST Mirren vs. Kilmarnock Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Kilmarnock 0:3 #STMirren#Kilmarnock 2026-05-09 14:00 UTC Aberdeen vs. Dundee Utd Predicted outcome: Aberdeen✅ Predicted score: 2:1 Actual: Aberdeen 2:0 #Aberdeen#DundeeUtd 2026-05-09 14:00 UTC Dundee vs. Livingston Predicted outcome: Dundee✅ Predicted score: 2:1 Actual: Dundee 3:0 #Dundee#Livingston 2026-05-09 14:00 UTC Falkirk vs. Hibernian Predicted outcome: Falkirk❌ Predicted score: 2:1 Actual: Hibernian 1:3 #Falkirk#Hibernian 2026-05-09 19:00 UTC Motherwell vs. Heart Of Midlothian Predicted outcome: Heart Of Midlothian❌ Predicted score: 1:2 Actual: Draw 1:1 #Motherwell#HeartOfMidlothian #Football#ScotlandPremiership

AI match predictions

@ai_match_prediction · Post #11438 · 11.04.2026 г., 09:06

Scotland Premiership🏴󠁧󠁢󠁳󠁣󠁴󠁿 2026-04-11 14:00 UTC Celtic vs. ST Mirren Predicted outcome: Celtic✅ Predicted score: 3:1 Actual: Celtic 1:0 #Celtic#STMirren 2026-04-11 14:00 UTC Kilmarnock vs. Dundee Predicted outcome: Kilmarnock❌ Predicted score: 2:1 Actual: Draw 2:2 #Kilmarnock#Dundee 2026-04-11 14:00 UTC Aberdeen vs. Hibernian Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Aberdeen 2:0 #Aberdeen#Hibernian 2026-04-11 14:00 UTC Heart Of Midlothian vs. Motherwell Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Heart Of Midlothian 3:1 #HeartOfMidlothian#Motherwell 2026-04-11 14:00 UTC Dundee Utd vs. Livingston Predicted outcome: Dundee Utd✅ Predicted score: 1:0 Actual: Dundee Utd 3:2 #DundeeUtd#Livingston #Football#ScotlandPremiership

AI match predictions

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

Scotland Premiership🏴󠁧󠁢󠁳󠁣󠁴󠁿 2026-03-21 15:00 UTC Kilmarnock vs. Livingston Predicted outcome: Kilmarnock✅ Predicted score: 2:1 Actual: Kilmarnock 2:0 #Kilmarnock#Livingston 2026-03-21 15:00 UTC Heart Of Midlothian vs. Dundee Predicted outcome: Heart Of Midlothian✅ Predicted score: 2:0 Actual: Heart Of Midlothian 1:0 #HeartOfMidlothian#Dundee 2026-03-21 15:00 UTC Motherwell vs. Hibernian Predicted outcome: Motherwell❌ Predicted score: 1:0 Actual: Draw 0:0 #Motherwell#Hibernian 2026-03-21 15:00 UTC Falkirk vs. ST Mirren Predicted outcome: Falkirk❌ Predicted score: 2:1 Actual: ST Mirren 1:2 #Falkirk#STMirren 2026-03-21 17:45 UTC Rangers vs. Aberdeen Predicted outcome: Rangers✅ Predicted score: 2:0 Actual: Rangers 4:1 #Rangers#Aberdeen #Football#ScotlandPremiership