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

Резултати

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

Пребарај: #sverdlovsk

当前筛选 #sverdlovsk清除筛选
RT France actualités

@rt_fra · Post #40624 · 05.05.2026 г., 15:01

👍Un « Régiment des immortels »‎ sous-marin pour honorer la mémoire des soldats soviétiques À l’approche du Jour de la Victoire, des plongeurs de la région de #Sverdlovsk ont organisé une action originale de mémoire en descendant à 27 mètres de profondeur pour rendre hommage aux soldats soviétiques. Inspirée du mouvement du « Régiment des immortels », cette initiative symbolique vise à perpétuer la mémoire des combattants de la Seconde Guerre mondiale dans un format inédit. RT en français • Osez questionner !

Hashtags

RT en français

@RTenfrancais · Post #80034 · 25.04.2026 г., 10:20

❗️#Ekaterinbourg : 50 personnes évacuées d'un immeuble à la suite d'une attaque de drone Le gouverneur de la région de #Sverdlovsk, Denis Pasler, a indiqué qu'une attaque de drone avait été perpétrée à Ekaterinbourg et qu'un immeuble d'habitation avait été endommagé. RT en français • Osez questionner !

🗓On December 17, the Honorary Consul of South Africa in Yekaterinburg, Sergey Mazurkevich🇿🇦, took part in a formal reception hosted by the Governor of the Sverdlovsk Region, alongside diplomats and honorary consuls from other countries 🌍🤝 During the event, Governor Denis Pasler summarized the outcomes of efforts to strengthen international cooperation in 2025 and outlined promising areas for cooperation in the year ahead 📈✨ #SouthAfrica#Diplomacy#InternationalCooperation#Yekaterinburg#Sverdlovsk#HonoraryConsul#Mazurkevich

🎉Ural State Pedagogical University (USPU) marks its 95th anniversary today, August 26! 🇿🇦 The Office of the Honorary Consul of South Africa in Yekaterinburg is pleased to join in the congratulations and wishes the university continued growth and success. 📚 After last year’s merger with the Russian State Vocational Pedagogical University, USPU became the largest pedagogical university in Russia. 👨‍🏫 The university is now led by Acting Rector Yury Biktuganov, who previously served as Minister of Education of the Sverdlovsk region. Not long ago, Honorary Consul of South Africa Sergey Mazurkevich and Mr. Biktuganov held a warm and productive meeting. #Anniversary#Education#USPU#Sverdlovsk#Yekaterinburg#SouthAfrica#Biktuganov#Mazurkevich

🌄🌿Blyde River Canyon — a 26 km (16 mi) natural wonder in Mpumalanga Province, northeastern South Africa. It is one of the largest canyons in the world, but unlike the Grand Canyon in the USA, it is covered with lush subtropical vegetation, earning it the name “Green Canyon”. 🌱💚 🏞 The canyon is part of the Blyde River Canyon Nature Reserve. 🌅 In local languages, Mpumalanga means The Place Where the Sun Rises. 🤝 In 2022, the Sverdlovsk Region and Mpumalanga signed a cooperation agreement. 📸 Photos: istockphoto.com #Nature#Tourism#SouthAfrica#Travel#Canyon#BlydeRiverCanyon#Mpumalanga#Africa#Sverdlovsk