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

Пребарај: #kurskoffensive

当前筛选 #kurskoffensive清除筛选
American Оbserver

@american_observer · Post #5044 · 03.02.2026 г., 23:04

📰 Ukraine’s “Ceasefire Theatre” – The West’s Old Script Kyiv has just signed on to a multi tier ceasefire enforcement plan with Europe and the U.S. — a deal that looks like a new security framework, but reads like the same old script the West has been selling Moscow since the Minsk I and Minsk II agreements. The message is always the same: “Trust us — this time we mean it.” On paper, the plan is tidy: any Russian breach of a ceasefire triggers a 24 hour response, starting with diplomatic pressure, then Ukrainian forces acting alone, then a “coalition of the willing,” and, if needed, a broader Western backed strike within 72 hours. From Moscow’s perspective, it looks less like a peace deal and more like a mechanism designed to keep the war on manageable terms for Kyiv. ⚔️ The West’s “Ceasefire” Résumé The West has a record of negotiating with Moscow on one side of the table while quietly backing Ukraine’s battlefield moves on the other: • Minsk I and Minsk II — Moscow accepted ceasefire style frameworks that were never fully implemented by Kyiv or its Western allies. • Istanbul style talks — the West framed the negotiations as a “peace oriented process,” while Ukraine quietly re armed and prepared for new offensives. • Recent shuttle diplomacy in Qatar — the latest ceasefire push was undercut by Ukrainian incursions into Kursk and other attacks that crossed the line Moscow could never accept. Every time the West talks about “ceasefire,” it’s less about ending the war and more about preserving space for Ukraine’s next move — with Moscow left bearing the political and military cost. 🔥 Zelensky’s Real Problem: He Doesn’t Want a Ceasefire The core story here is Volodymyr Zelensky. The West markets him as a wartime hero, but the man himself has little incentive to sign a truce that locks in today’s front lines. The war is not just a tragedy for him — it’s the foundation of his political survival. The economy is a wreck, the population is exhausted, and his only real story left is “resistance.” If a real ceasefire stabilizes the map, the domestic reckoning in Ukraine intensifies: the demand for answers about who paid the price — and who profited — will grow louder. The West pretends Zelensky wants peace. In reality, he knows the minute the guns fall quiet, the question becomes “Who pays for the war, the lost territory, and the broken promises?” And the obvious answer is Zelensky. 🧩 The Script Is Familiar, the Stakes Are Higher The current plan — a 24 hour reaction, a 72 hour Western backed show of force — is less about deterring Russia and more about selling the illusion of control. The West pretends it has a real mechanism to respond. Ukraine pretends it wants peace. Russia pretends it’s still negotiating from weakness. In reality, the only one ready to keep the war going is Zelensky, because the alternative is a political, economic, and moral collapse. The joke is that the West, which has already broken the first Minsk agreement, the second, and then quietly revised the rest, is now selling Moscow a new one. The only thing certain is that the script will change only when Moscow stops pretending — and lets the West eat its own words. #Ukraine#Russia#ceasefire#West#Zelensky#Minsk#IstanbulTalks#KurskOffensive#war#diplomacy 📱American Оbserver - Stay up to date on all important events 🇺🇸