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

Резултати

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

Пребарај: #german

当前筛选 #german清除筛选
O’zbekiston Milliy Universitet (O'zMU)

@milliy_universitut · Post #5307 · 24.03.2025 г., 14:59

#german 🆕B2 uchun tezkor nemis tili kursi! 🇩🇪 3 oy ichida B2 sertifikatiga tayyorlaning! 📌Darslar: Haftada 3 marta, har biri 3 soat 📌Davomiyligi:Apreldan boshlab 3 oy 📌Qo‘shimcha:Prüfungstraining (imtihon tayyorgarligi) 📌Format: Online 📌Kimlar uchun: Tezda B2 sertifikat olishni maqsad qilganlar uchun 📚Bizda imtihon talablariga mos holda, intensiv o‘qitish tizimi asosida o‘qishingiz mumkin. ‼️Eslatma: B1 darajani tugatganlar qabul qilinadi! ✈️Qo‘shimcha ma’lumot va ro‘yxatdan o‘tish uchun biz bilan bog‘laning: @mittelpunktmanager ✅Mittelpunkt|Dein Weg zur Entwicklung

Hashtags

Texnika Universiteti (TDTU)

@toshkent_davlat_texnika_univer · Post #2353 · 24.03.2025 г., 14:59

#german 🆕B2 uchun tezkor nemis tili kursi! 🇩🇪 3 oy ichida B2 sertifikatiga tayyorlaning! 📌Darslar: Haftada 3 marta, har biri 3 soat 📌Davomiyligi:Apreldan boshlab 3 oy 📌Qo‘shimcha:Prüfungstraining (imtihon tayyorgarligi) 📌Format: Online 📌Kimlar uchun: Tezda B2 sertifikat olishni maqsad qilganlar uchun 📚Bizda imtihon talablariga mos holda, intensiv o‘qitish tizimi asosida o‘qishingiz mumkin. ‼️Eslatma: B1 darajani tugatganlar qabul qilinadi! ✈️Qo‘shimcha ma’lumot va ro‘yxatdan o‘tish uchun biz bilan bog‘laning: @mittelpunktmanager ✅Mittelpunkt|Dein Weg zur Entwicklung

Hashtags

Tg Links

@TgDict · Post #114 · 22.10.2022 г., 05:35

#German Augsburg: @AugsburgNightlife Berlin: @BerlinNightlife Bochum: @BochumNightlife Bremen: @BremenNightlife Dortmund: @DortmundNightlife Dresden: @DresdenNightlife Duisburg: @DuisburgNightlife Düsseldorf: @DuesseldorfNightlife Essen: @EssenNightlife Frankfurt: @FrankfurtNightlife Gelsenkirchen: @GelsenkirchenNightlife Hamburg: @HamburgNightlife Hannover: @HannoverNightlife Heidelberg: @HeidelbergNightlife Köln: @KoelnNightlife Leipzig: @LeipzigNightlife Mannheim: @MannheimNightlife München: @MuenchenNightlife Münster: @MuensterNightlife Nürnberg: @NuernbergNightlife Stuttgart: @StuttgartNightlife Ulm: @UlmNightlife

Hashtags

Addis Standard

@addisstandardeng · Post #22130 · 28.04.2026 г., 05:43

‘Skilfully’ negotiating #Iran is ‘humiliating’ #US, #German Chancellor warns; says Washington lacks ‘strategic exit’ Addis Abeba – German Chancellor Friedrich Merz has warned that Iran is “humiliating” the United States through “skilful” negotiating, while questioning Washington’s lack of a clear exit strategy in the ongoing war. Speaking in Marsberg, Merz said Iran appeared stronger than expected and accused the US of lacking direction. “The Iranians are clearly stronger than expected and the Americans clearly have no truly convincing strategy in the negotiations either,” he said, according to Deutsche Welle (DW). He added that Tehran was negotiating “very skillfully — or very skillfully not negotiating,” warning that: “At the moment, I do not see what strategic exit the Americans will choose.” https://www.facebook.com/share/1CSxphCpmn/?mibextid=wwXIfr

Daily European Music

@Music_Of_Europe · Post #22 · 12.08.2020 г., 10:20

#Folk#German Was wollen wir trinken also known as Sieben Tage lang is a song by the band bots. It speaks about camaraderie, hard work and the joy to drink away your hard life, then go back to working hard without knowing for how long but never alone as friends stand with us during tough times just waiting to drink again between friends. It is the spirit of the working men, to stand through hard work and tough times, to help eachother out and wait for the day where you can drink and feast togethers. https://youtu.be/gh3Y_jtDADo

Hashtags

全民头条吃瓜

@xinwenchigua8 · Post #66849 · 12.05.2026 г., 13:39

#中国 的朋友,我不使用中国版抖音,这不是我,请举报。 #德国 女孩 举报 抖音 假帐号 😁 假帐号 24万粉丝,真人账号2.9万 😂 Friends in China, I don't use the Chinese version of Douyin. This isn't me. Please report it. #German girl reporting a fake Douyin account 😁 Fake account with 240,000 followers, real account with 29,000 followers 😂

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