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

Резултати

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

Пребарај: #zatoka

当前筛选 #zatoka清除筛选
DruschbaFM - English

@druschbaFm_en · Post #52374 · 21.03.2025 г., 08:06

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 21 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west near #Zhuravka the RFAF are around 2 km deep in Ukrainian lands. The village itself, is ca. 50% under Russian control. 🟡#Basovka, to the southeast, is about 70% seized. 🟡#Novenkoye, further north, is Russian controlled. The AFU have abandoned the settlement. 🟡 The border zone to the east is grey zone. 🟡#Rubanshchina in #Kursk region, is Russian controlled. 🟡#Gogolevka to its east is still under AFU control. 🟡 Southeast of #Gogolevka, the RFAF expanded their zone of control. The wedge is also north #Melovoy, the control of which is unclear (AFU or Grey Zone). 🟡#Oleshnyaremains safe under AFU control. 🟡#Guyevo is likely still AFU controlled, the RFAF expanded their zone and have advanced close to its northern edge. 🟡#Gornal remains safe under AFU control. 📌 As a Result, there no cauldron for now. UAV and artillery are working on both sides. In fact, the AFU losses are far higher than the RFAF's, which is well documented by objective evidence. This, due to the AFU Command's decision to hold the remaining villages at any costs. 🔴 In #KrasnayaYaruga Sector, south of #Sudhza in Russian #Belgorod region, the AFU assaults continue with focus on #Demidovka, where AFU infantry could entrench at its southern edge. Shooting battles have been reported. According to unconfirmed reports, the village ruins are still Russian controlled. 🟡#Grafovka to its southeast remains under firm Russian control. 🟡#Prilesye also further south. 🗺 All on Map 1 📌 The AFU Command, following significant losses of tanks and armoured vehicles, has changed its tactics. Attacks are now only carried out by infantry groups with drone and artillery support. 🔴 In #Kharkov Direction and at #Svatovo Front, there are no major changes. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, no changes. 🔴In #Toretsk Sector, northeast of the city, the reported RFAF advance towards #Ozeryanovka has been confirmed by footage. 🟡 At #Druzhba, the RFAF expanded the zone of control north of the village by around 600m. 🟡 In #Toretsk, the RFAF had tactical successes. 🔴#Pokrovsk Direction: 🔴 On the right Flank, the AFU counterattack and managed to push back Russian units in the area of ​​the 'Malinovskaya junction.' 🟡#Tarasovka has been entered by Russian assault groups, which managed to expand the control zone in the village by 400m. 🗺 Map 2 🎬 Video 🟡 In #Yelizavetovka, there are heavy counterbattles. 🔴 South of the City, contrary to earlier reports, #Shevchenko village is still embattled. Russian troops expanded their zone of control. 🗺 Map 3 🔴 On the left Flank, heavy fighting without significant changes. 🔴#Komar Direction: 🔴In #Konstantinopol Sector, the battles incl. for #Konstantinopol itself continue, no major changes. 🔴 In #Komar Sector, heavy fighting continues. According to field reports, the Russian troops have entered the southern outskirts of #Vesyoloye. 🔴#Zaporozhye Direction: 🔴In the #Orekhov Section, bloody battles for #Shcherbaki and #MalyeShcherbaki, as well as on the approaches to #Lobkovoye continue. 🔴 In #Kherson Direction, the AFU struck civil targets. 💥#OldRussia: 🔵In #Kursk Region, the AFU struck and destroyed the 'Sudzha Gas Transmission System,' through which gas from #Russia was supplied to the #EU. In #Rostov region, a UAV attack was repelled at night. In the #DPR, 1 civilian was killed and 4 wounded by AFU attacks on civilian targets. 💥#RestUkraine: 🔵 In #Odessa Region, several Geranium UAV hits have been reported, incl. at the 'Telekart-Pribor Plant' in #Odessa. Explosions occurred also in #Zatoka, #Kiev, #Poltava, #Zaporozhye, and #Cherkassy regions. 🎞 Video Source 🗺 Maps @olegtsarov; @creamy_caprice 📋 Sources: CC; Tsarov; ⚡️2M; 🇺🇦Fiend;😼Kotenok 🕰As of 21 Mar 2025; 06:42 GMT+3;📃20 Mar 📱 Join GLOBAL DEPTH to boost your TG Feed 💬Join Military Chat for Comments & Discussions 🇺🇦On Ukraine Observer you will find your daily independent Ukraine War Battle Update