TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #22 · 19 јан.

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

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

Пребарај: #bessonovka

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

@druschbaFm_en · Post #52561 · 26.03.2025 г., 07:58

⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 26 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, to the west on Ukrainian lands, for a RFAF presence at #Vladimirovka evidence is still missing (1st blue arrow on map). 🟡 For #Veselovka, the battle continues (1st black arrow). 🟡 In #Zhuravka as well. 🟡#Basovka is at best 50% RFAF controlled. 🟡#Novenkoye, is Russian controlled (1st red arrow). 🟡 In #Kursk region, according to unconfirmed reports, the 'Sudza Gas Transmission Point' is under RFAF control and the battle for the nearby border checkpoint continues (4th black arrow). 🟡#Gogolevka remains under full AFU control (2nd blue arrow). Contrary reports are unproven. 🟡#Melovoy came under the control of Russian troops, which advanced further westwards towards #Oleshnya (2nd red arrow). 🟡#Oleshnya, #Guyevo and #Gornal remain under AFU control for now. 🔴In #KrasnayaYaruga Sector, the AFU 8th Special Forces Regiment and 'Aidar' Nationalists failed to take #Popovka (5th black arrow). Over the past day, the AFU razed the village to the ground with artillery and drones. 🟡 In #Demidovka, nearby to the southeast, Small AFU groups enter periodically, uncapable to take the village (6th black arrow). 🟡 At #Grafovka, lull. 🟡 West of #Prilesye, the AFU have been driven out from Russian territory. 🗺 All on Map 1 🔴 In #Kharkov Direction, positional battles continue In the areas of #Lipsy and #​​Volchansk. A large number of drones, artillery and aircraft are used. 🔴#Svatovo Front: 🔴 In #Kupyansk Sector, north of the city, Russian forces created a new bridgehead between #Kamenka and #Krasnoye1st. In the area of #​​Dvurechnaya, the battles continue, as well as on the #Zapadnoye - #Kalinovo line. 🔴 In #Borovaya, #Liman and #Seversk Sectors, without major changes. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, heavy urban battles continue in 'Shevchenko Microdistrict' in the southern part of the city. To the south, fighting in the area of #Stupochki. 🔴In #Toretsk Sector, the RFAF continue attempts to take the city, increasing the pressure in its north. 🔴#Pokrovsk Direction: 🔴 On the right Flank, far to the east, Russian troops attack southwest of #Aleksandropol and try to straighten the front. 🔴 South of the City and on the left Flank, no changes. 🔴#Komar Direction: 🔴In #Konstantinopol Sector, the battle for the same named village continues. 🟡 Southeast of #Razliv, the RFAF advanced on a broad front, extending the zone of control in an area up to 4 km wide and up to 2.05 km deep, approaching the settlement located southwest of #Konstantinopol. 🔴 In #Komar Sector, Russian forces repulsed AFU counterattacks in the areas of the #Vesyoloye and #VolnoyePole settlements. 🔴#Zaporozhye Direction: 🔴In #Orekhov Section, the situation based on confirmed and evidenced data has improved for the RFAF: 🟡 In #Shcherbaki, the AFU lost full control. 🟡 In nearby #MalyeShcherbakito the west, the RFAF have advanced. The AFU still hold positions in its far northeast. 🟡 In #Stepovoye's, further west, there are heavy fights in the village. 🎬 Video 1 🗺 Map 2 🟡 In #Lobkovoye, the the RFAF advanced northwards. About 50% of the village came under Russian control. 🗺 Map 2 🟡 #​​Pyatikhatki, came under full RFAF control yesterday. 🗺 Map 2 🔴 In #Kherson Direction, no changes. 💥#OldRussia: 🔵 In #Belgorod Region, civil objects in #Politodelsky, #Kazinka, #Shebekino, #Tishanka and #Bessonovka came under AFU attack. 💥#RestUkraine: 🔵 The RFAF targeted AFU facilities and militants in #Zaporozhye, #Nikolayev and #Dnepropetrovsk, as well as in #Sumy, #Poltava and #Cherkassy regions. 🟡 In #KrivoyRog, more than 15 explosions occurred overnight. 🎬 Video 2 🎞 Vids Source 1; Source 2; 🗺 Maps @olegtsarov; @creamy_caprice 📋 Sources: CC; Tsarov; ⚡️2M; 🇺🇦Fiend;😼Kotenok 🕰As of 26 Mar 2025; 06:41 GMT+3;📃25 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