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

Пребарај: #ivanovka

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

@druschbaFm_en · Post #52910 · 06.04.2025 г., 08:02

⚡️ 🇷🇺 🇺🇦📆 Weekly Ukraine War Roundup⚡️ 🗣 The Past Week saw continued global turbulence. The spotlight was on Trump’s introduction of sweeping protective tariffs, signalling a move towards super-protectionism. The era of globalism and idealistic notions of 'international division of labour' is fading, , giving way to intensifying trade wars. Washington aims to bring real industrial production back to the #US, streamline spending, and balance trade, particularly with #China. #EU officials voiced concern, but antiwar protests in cities like #Rome, with slogans like 'We need hospitals, not missiles,' better reflect public sentiment. Meanwhile, #Europe’s elite exploits the 'War with Russia' narrative to serve arms lobbies and divert funds from social programmes. The #US also saw protests, mainly driven by the societal split after years of liberal-fascist propaganda from Biden’s camp and its allies. 🇷🇺 In Diplomacy, the arrival of Dmitriev, envoy of the Supreme, in the #US was notable. His talks focused less on peace in #Ukraine and more on the economic benefits of working with us, compared to the costly, unconditional arms deliveries to Kiev. 🔸 Such Meetings are often spun at home as signs of a 'coming end to the war' which is misleading. Unquestioning belief in this narrative has weakened logistical support for the front and sparked rumours among troops about an imminent ceasefire. This undermines morale among fighters and officers, who see it as premature compromise. ⚔️ On the Fronts, while the RFAF maintain strategic initiative, the AFU is carrying out a defensive operation to slow our advance along the Line of Contact. 🔴 In the Invasion Zone, the AFU still hold #Kursk border settlements, while the RFAF fight deeper into #Sumy region. Battles continue at #Popovka and #Demidovka in #Belgorod region, with the AFU reinforcing across the border. Signals indicate they retain reserves for further provocations. In #Bryansk region, officials finally acknowledged daily AFU shelling of civilians, though some incidents go unreported, frustrating locals and raising doubts about regional control. 🔴 On the #Svatovo Front, north of #Kupyansk, the RFAF expand their bridgehead on the Oskol’s right bank. Southward, intense fighting continues. On the #Liman axis, control expands from #Katerinovka to #Ivanovka. 🔴 At #ChasovYar, fighting with little movement. Near #Konstantinovka, we have engaged in battles at #Andreyevka. After weeks of combat in #Toretsk, we shifted southward, taking #Panteleymonovka and #Aleksandropol, fierce clashes rage in #Tarasovka and at #ZelenoyePole. 🔴 Around #Pokrovsk, momentum has shifted, Russian troops now advancing in #Lysovka. 🔴 In #Komar Direction, clashes continue south of #Razliv, at #Vesyoloye and #VolnoyePole. 🔴 On the #Zaporozhye Front, Russian forces took #Lobkovoye after gains at #Shcherbaki and #Stepovoye. Reportedly renewed action at #Kamenskoye. In #Kherson region, mutual strikes, and the RF Aerospace Forces increased FAB use this week. 💥 A recent AFU Strike on a key fibre-optic plant highlighted weaknesses in our air defences. Command inertia, underuse of anti drone tools, poor coordination, and lack of accountability among senior officers still lead to avoidable damage, despite most UAVs being downed, often over towns. Low pay and unfair compensation remain concerns among air defence crews. ❇️ In Summary, any 'societal relaxation' amid continued heavy fighting and Kiev’s consistent disregard for agreements, while the #US keeps supplying arms and intelligence to the AFU, looks naive. Mocking the AFU or potential adversaries has already cost Russia dearly, leading to the war now entering its 4th year. 📌 Notes: A Russian view; in supplement: In #Toretsk itself, the RFAF also advanced. In #Basovka the battle has shiftet to its southern part (Sumy).🗺👆 🗺 Map CC;📋Source: 2M 🕰As of 6 Apr 2025; 07:22 GMT+3 📃5 Apr;#sum 📱 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