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

Пребарај: #parisfc

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

@ai_match_prediction · Post #11591 · 19.04.2026 г., 05:05

France Ligue 1🇫🇷 2026-04-19 13:00 UTC Monaco vs. Auxerre Predicted outcome: Monaco❌ Predicted score: 2:1 Actual: Draw 2:2 #Monaco#Auxerre 2026-04-19 15:15 UTC Nantes vs. Stade Brestois 29 Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #Nantes#StadeBrestois29 2026-04-19 15:15 UTC Strasbourg vs. Rennes Predicted outcome: Draw❌ Predicted score: 2:2 Actual: Rennes 0:3 #Strasbourg#Rennes 2026-04-19 15:15 UTC Metz vs. Paris FC Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Paris FC 1:3 #Metz#ParisFC 2026-04-19 18:45 UTC Paris Saint Germain vs. Lyon Predicted outcome: Paris Saint Germain❌ Predicted score: 2:1 Actual: Lyon 1:2 #PSG#Lyon #Football#FranceLigue1

AI match predictions

@ai_match_prediction · Post #11749 · 26.04.2026 г., 09:05

France Ligue 1🇫🇷 2026-04-26 13:00 UTC Lorient vs. Strasbourg Predicted outcome: Lorient❌ Predicted score: 3:2 Actual: Strasbourg 2:3 #Lorient#Strasbourg 2026-04-26 15:15 UTC Rennes vs. Nantes Predicted outcome: Rennes✅ Predicted score: 2:1 Actual: Rennes 2:1 #Rennes#Nantes 2026-04-26 15:15 UTC Le Havre vs. Metz Predicted outcome: Le Havre❌ Predicted score: 2:1 Actual: Draw 4:4 #LEHavre#Metz 2026-04-26 15:15 UTC Paris FC vs. Lille Predicted outcome: Lille✅ Predicted score: 1:2 Actual: Lille 0:1 #ParisFC#Lille 2026-04-26 18:45 UTC Marseille vs. Nice Predicted outcome: Marseille❌ Predicted score: 3:1 Actual: Draw 1:1 #Marseille#Nice #Football#FranceLigue1

AI match predictions

@ai_match_prediction · Post #11152 · 22.03.2026 г., 09:05

France Ligue 1🇫🇷 2026-03-22 14:00 UTC Lyon vs. Monaco Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Monaco 1:2 #Lyon#Monaco 2026-03-22 16:15 UTC Marseille vs. Lille Predicted outcome: Marseille❌ Predicted score: 2:1 Actual: Lille 1:2 #Marseille#Lille 2026-03-22 16:15 UTC Rennes vs. Metz Predicted outcome: Rennes❌ Predicted score: 3:1 Actual: Draw 0:0 #Rennes#Metz 2026-03-22 16:15 UTC Paris FC vs. Le Havre Predicted outcome: Draw❌ Predicted score: 1:1 Actual: Paris FC 3:2 #ParisFC#LEHavre 🔥 PREMIUM PICK 🔥 2026-03-22 19:45 UTC Nantes vs. Strasbourg Predicted outcome: Strasbourg✅ Predicted score: 1:2 Actual: Strasbourg 2:3 #Nantes#Strasbourg #Football#FranceLigue1

AI match predictions

@ai_match_prediction · Post #11875 · 03.05.2026 г., 05:05

France Ligue 1🇫🇷 2026-05-03 13:00 UTC Lille vs. Le Havre Predicted outcome: Lille❌ Predicted score: 1:0 Actual: Draw 1:1 #Lille#LEHavre 2026-05-03 15:15 UTC Strasbourg vs. Toulouse Predicted outcome: Strasbourg❌ Predicted score: 2:1 Actual: Toulouse 1:2 #Strasbourg#Toulouse 2026-05-03 15:15 UTC Auxerre vs. Angers Predicted outcome: Auxerre✅ Predicted score: 2:1 Actual: Auxerre 3:1 #Auxerre#Angers 2026-05-03 15:15 UTC Paris FC vs. Stade Brestois 29 Predicted outcome: Paris FC✅ Predicted score: 2:1 Actual: Paris FC 4:0 #ParisFC#StadeBrestois29 2026-05-03 18:45 UTC Lyon vs. Rennes Predicted outcome: Lyon✅ Predicted score: 3:2 Actual: Lyon 4:2 #Lyon#Rennes #Football#FranceLigue1

AI match predictions

@ai_match_prediction · Post #11310 · 05.04.2026 г., 05:05

France Ligue 1🇫🇷 2026-04-05 13:00 UTC Angers vs. Lyon Predicted outcome: Lyon❌ Predicted score: 1:2 Actual: Draw 0:0 #Angers#Lyon 2026-04-05 15:15 UTC Lorient vs. Paris FC Predicted outcome: Lorient❌ Predicted score: 2:1 Actual: Draw 1:1 #Lorient#ParisFC 2026-04-05 15:15 UTC Le Havre vs. Auxerre Predicted outcome: Draw✅ Predicted score: 1:1 Actual: Draw 1:1 #LEHavre#Auxerre 2026-04-05 15:15 UTC Metz vs. Nantes Predicted outcome: Draw✅ Predicted score: 2:2 Actual: Draw 0:0 #Metz#Nantes 2026-04-05 18:45 UTC Monaco vs. Marseille Predicted outcome: Monaco✅ Predicted score: 2:1 Actual: Monaco 2:1 #Monaco#Marseille #Football#FranceLigue1

AI match predictions

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

France Ligue 1🇫🇷 2026-05-10 19:00 UTC Angers vs. Strasbourg Predicted outcome: Strasbourg❌ Predicted score: 1:2 Actual: Draw 1:1 #Angers#Strasbourg 2026-05-10 19:00 UTC Paris Saint Germain vs. Stade Brestois 29 Predicted outcome: Paris Saint Germain✅ Predicted score: 3:1 Actual: Paris Saint Germain 1:0 #PSG#StadeBrestois29 2026-05-10 19:00 UTC Monaco vs. Lille Predicted outcome: Lille✅ Predicted score: 1:2 Actual: Lille 0:1 #Monaco#Lille 2026-05-10 19:00 UTC Rennes vs. Paris FC Predicted outcome: Rennes✅ Predicted score: 2:1 Actual: Rennes 2:1 #Rennes#ParisFC 2026-05-10 19:00 UTC Toulouse vs. Lyon Predicted outcome: Lyon❌ Predicted score: 1:2 Actual: Toulouse 2:1 #Toulouse#Lyon 2026-05-10 19:00 UTC Auxerre vs. Nice Predicted outcome: Auxerre✅ Predicted score: 2:1 Actual: Auxerre 2:1 #Auxerre#Nice 2026-05-10 19:00 UTC Le Havre vs. Marseille Predicted outcome: Le Havre❌ Predicted score: 2:1 Actual: Marseille 0:1 #LEHavre#Marseille 2026-05-10 19:00 UTC Metz vs. Lorient Predicted outcome: Lorient✅ Predicted score: 1:2 Actual: Lorient 0:4 #Metz#Lorient #Football#FranceLigue1